Hi i have self hosted parse server on digital ocean, it is sending notifications on iOS but not on android. my index.js file looks like this:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://1.1.1.1"1/app_name',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: 'abc',
masterKey: 'def',
serverURL: 'http://1.1.1.1:1337/parse' || 'http://localhost:1337/parse',
verbose: true,
push: {
android:{
senderId: 'my FCM id',
apiKey: 'my FCM key'
},
ios: {
pfx: '1',
bundleId: '2',
production: true
}
}
});
when i send a push from the parse dashboard (also self hosted), this is the response i get with verbose:true:
"results": [
{
"objectId": "bNtZqwY8",
"pushTime": "2017-06-13T10:49:06.095Z",
"query": "{\"UniqueId\":\"c49de788ce\",\"deviceType\":{\"$in\":[\"android\"]}}",
"payload": "{\"alert\":\"Thank you for using my app.\"}",
"source": "rest",
"status": "succeeded",
"numSent": 0,
"pushHash": "266b6b637152b36040830",
"createdAt": "2017-06-13T10:49:06.095Z",
"updatedAt": "2017-06-13T10:49:06.214Z",
"numFailed": 15,
"failedPerType": {
"android": 15
},
"ACL": {}
},
{
"objectId": "rsYinvGG",
"pushTime": "2017-06-13T10:48:42.449Z",
"query": "{\"UniqueId\":\"7A0A-9AEA-5870FDEC42A3\"}",
"payload": "{\"alert\":\"one\",\"link_key\":1,\"sound\":\"default\"}",
"source": "rest",
"status": "succeeded",
"numSent": 2,
"pushHash": "246431e019c0357dcb180c7",
"createdAt": "2017-06-13T10:48:42.449Z",
"updatedAt": "2017-06-13T10:48:43.282Z",
"numFailed": 0,
"sentPerType": {
"ios": 2
},
"ACL": {}
},
When i send push on android from FCM, it works. Im really lost here with android push, can someone please point me in the right direction.
Here is the output from the log:
ESC[36mverboseESC[39m: REQUEST for [PUT] /parse/classes/_Installation /zKIp8LLOWr: {
"GCMSenderId":"diMV6Hm3j07dbqVPEsZRgqNzDo3YvA5zNdUmtO6Q4ka5ijRyyIRHiWCWOBVBDA22OIls-4bO06kxDPuOKFwJUZuMD3Xt41WuKUoOJwBlW7cKdqv9llj7Me0uiWFLWDwS7V",
"UniqueId": "a59020fff8ca30d00",
"appVersion": "2.3.3",
"objectId": "zKIp8LLOWr"
} method=PUT, url=/parse/classes/_Installation/zKIp8LLOWr, x-parse- app-display-version=2.3.3, x-parse-installation-id=29918e2f-8bbd-4ab7-975f-f854e1f43689, user-agent=Parse Android SDK 1.13.1 (com.mrfizzy/18) API Level 21, connection=Keep-Alive, accept-encoding=gzip, x-parse-os-version=5.0, x-parse-app-build-version=18, content-type=application/json, x-parse-client-key=, x-parse-client-version=a1.13.1, host=46.101.199.219:1337, content-length=245, x-parse-application-id=JHyfl9YhXCQ24r6J8ohdVlHLt1hfWhB4MF2jQAQn, GCMSenderId=diMV6HmLH3I:APA91bFQS4Sq9G5wlej07dbqVPEsZRgqNzDo3YvA5zNdUmtO6Q4ka5ijRyyIRHiWCWOBVBDA22OIls-4bO06kxDPuOKFwJUZuMD3Xt41WuKUoOJwBlW7cKdqv9llj7Me0uiWFLWDwS7V, UniqueId=a59020a48ca30d00, appVersion=2.3.3, objectId=zKIp8LLOWr
ESC[31merrorESC[39m: Error generating response. ParseError { code: 101, message: 'Object not found for update.' } code=101, message=Object not found for update.
[object Object]
It appears you're not assigning the Sender Id properly. You're passing an objectId that doesn't seem to be correct. Make sure you use ParseInstallation.getCurrentInstallation() when you set your GCM sender id rather than trying to get the installation by any other means.
http://parseplatform.org/Parse-SDK-Android/api/com/parse/ParseInstallation.html#getCurrentInstallation()
Related
I'm using Firebase to send message across iOS & Android devices. I follow the document of google but it's still not working.
https://firebase.google.com/docs/cloud-messaging/concept-options
In the document, they gave an example
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"title":"Match update",
"body":"Arsenal goal in added time, score is now 3-0"
},
"android":{
"ttl":"86400s",
"notification"{
"click_action":"OPEN_ACTIVITY_1"
}
},
"apns": {
"headers": {
"apns-priority": "5",
},
"payload": {
"aps": {
"category": "NEW_MESSAGE_CATEGORY"
}
}
},
"webpush":{
"headers":{
"TTL":"86400"
}
}
}
}
and I replaced some placeholders of this example with my Firebase configurations then I ran Postman and it returned 400 bad Request
{
"message":{
"token":"dRnhMNngY02mofqQ-5no8K:APA91bEcaaZ3QBWTdZfN3hU1tJzy6_ChW4FMArXbbWvT-8wq11TDN2jLy7uaT-Wzjq_xAzPqZfVje5_n54pVLnCfUUPTp_EuS3CykGnysHO0BeJn0TEgP-czc_y2kdyVMW-39mlSh8-t",
"notification":{
"title":"Match update",
"body":"Arsenal goal in added time, score is now 3-0"
},
"android":{
"ttl":"86400s",
"notification": {
"click_action":"OPEN_ACTIVITY_1"
}
},
"apns": {
"headers": {
"apns-priority": "5"
},
"payload": {
"aps": {
"category": "NEW_MESSAGE_CATEGORY"
}
}
},
"webpush":{
"headers":{
"TTL":"86400"
}
}
}
}
But when I changed it. Set to & notification to the first level of json. My iOS device displayed a notification.
{
"to": "dRnhMNngY02mofqQ-5no8K:APA91bEcaaZ3QBWTdZfN3hU1tJzy6_ChW4FMArXbbWvT-8wq11TDN2jLy7uaT-Wzjq_xAzPqZfVje5_n54pVLnCfUUPTp_EuS3CykGnysHO0BeJn0TEgP-czc_y2kdyVMW-39mlSh8-t",
"notification": {
"title": "Match update",
"body": "Arsenal goal in added time, score is now 3-0"
}"message": {
"token": "dRnhMNngY02mofqQ-5no8K:APA91bEcaaZ3QBWTdZfN3hU1tJzy6_ChW4FMArXbbWvT-8wq11TDN2jLy7uaT-Wzjq_xAzPqZfVje5_n54pVLnCfUUPTp_EuS3CykGnysHO0BeJn0TEgP-czc_y2kdyVMW-39mlSh8-t",
"notification": {
"title": "Match update",
"body": "Arsenal goal in added time, score is now 3-0"
},
"android": {
"ttl": "86400s",
"notification": {
"click_action": "OPEN_ACTIVITY_1"
}
},
"apns": {
"headers": {
"apns-priority": "5"
},
"payload": {
"aps": {
"category": "NEW_MESSAGE_CATEGORY"
}
}
},
"webpush": {
"headers": {
"TTL": "86400"
}
}
}
}
I don't know why the example of Firebase from Google is not working? Moreover, I tried to send to my Android device, it said "InvalidRegistration" message but when I tested sending message in https://console.firebase.google.com -> Cloud Messaging -> Compose notification. I pasted the same token that I used to test Android and it worked...
Really confused?!
I found several articles and test but it did work for me. I just want to have a structure of json file to work for both iOS and Android (also need to send both type of message as: notification & data)
Can anyone help me to fix this issue?
Thank you a lot,
Just want to up this question and not to be missed
**[11:12] Umer Saleem
Working on it, sir in this example link what is the components name and how to find it
POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/{component_name}/commands/{command_name}
**
To find out what components you have for this device, you can do a GET request to
https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/
This will show you the components, a sample response can be:
{
"value": [
{
"#id": "urn:machine:MyMachine:lxhc64xu:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_7d7",
"displayName": "Interface"
},
{
"#id": "urn:machine:MyMachine:_lyh_e2x:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_282",
"displayName": "Properties"
}
]
}
The name of the {component} is the name of the value that you get in the response. In my example, you can use "cb_7d7" or "cb_282". They are the names of your interfaces.
I have implemented access to OneDrive files using the Graph SDK from https://github.com/microsoftgraph/msgraph-sdk-android
For Authentication, I am using the same approach as in the Connect sample which uses the MSAL library, i.e. compile ('com.microsoft.identity.client:msal:0.1.+')in the build.gradle file.
I am calling mPublicClientApp.acquireToken with
String[] scopes = {"offline_access", "https://graph.microsoft.com/Files.ReadWrite","https://graph.microsoft.com/User.Read"}; and successfully retrieve accessTokens for both personal accounts and business accounts.
Next, I want to store a file on the user's OneDrive using
client.getDrive()
.getRoot()
.getItemWithPath("file.txt")
.getContent()
.buildRequest()
.put(data);
which works as expected with a personal account but fails with 403: Forbidden when using my business account (which BTW is the user of the app in the Azure portal). Similarly, I get 404: Not found if I try to get the DriveItem for a file which does exist (and that works for the personal account as well).
Is there anything wrong with my code or does it look like wrong configuration of the app? (I am using the "preview mode" in Azure portal). The permissions I have added are
Files.ReadWrite
Delegiert
Have full access to user files
-
offline_access
Delegiert
Access user's data anytime
-
User.Read
Delegiert
Sign in and read user profile
-
User.ReadWrite
Delegiert
Read and write access to user profile
-
This is my full manifest (with some IDs removed):
{
"id": "...",
"acceptMappedClaims": null,
"accessTokenAcceptedVersion": 2,
"allowPublicClient": true,
"appId": "...",
"appRoles": [],
"oauth2AllowUrlPathMatching": false,
"createdDateTime": "2018-12-24T08:51:51Z",
"groupMembershipClaims": null,
"identifierUris": [
"api://..."
],
"informationalUrls": {
"termsOfService": null,
"support": null,
"privacy": null,
"marketing": null
},
"keyCredentials": [],
"knownClientApplications": [],
"logoUrl": null,
"logoutUrl": null,
"name": "...",
"oauth2AllowIdTokenImplicitFlow": false,
"oauth2AllowImplicitFlow": false,
"oauth2Permissions": [
{
"adminConsentDescription": "blub",
"adminConsentDisplayName": "bla",
"id": "d3659b01-433e-44eb-ab39-9ee9c19f7fe8",
"isEnabled": true,
"lang": null,
"origin": "Application",
"type": "User",
"userConsentDescription": null,
"userConsentDisplayName": "read files",
"value": "Files.ReadWrite"
}
],
"oauth2RequirePostResponse": false,
"optionalClaims": null,
"orgRestrictions": [],
"parentalControlSettings": {
"countriesBlockedForMinors": [],
"legalAgeGroupRule": "Allow"
},
"passwordCredentials": [],
"preAuthorizedApplications": [],
"publisherDomain": "crocoapps.onmicrosoft.com",
"replyUrlsWithType": [
{
"url": "https://login.microsoftonline.com/common/oauth2/nativeclient",
"type": "InstalledClient"
},
{
"url": "msal8374f.................d9b2://auth",
"type": "InstalledClient"
},
{
"url": "https://login.live.com/oauth20_desktop.srf",
"type": "InstalledClient"
}
],
"requiredResourceAccess": [
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "7427e0e9-2fba-42fe-b0c0-848c9e6a8182",
"type": "Scope"
},
{
"id": "5c28f0bf-8a70-41f1-8ab2-9032436ddb65",
"type": "Scope"
},
{
"id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
"type": "Scope"
},
{
"id": "b4e74841-8e56-480b-be8b-910348b18b4c",
"type": "Scope"
}
]
}
],
"samlMetadataUrl": null,
"signInUrl": null,
"signInAudience": "AzureADandPersonalMicrosoftAccount",
"tags": [],
"tokenEncryptionKeyId": null
}
I think your replyUrlsWithType values aren't holding the correct values. This list should hold the URLs to which Azure AD will redirect to once a token is issued.
Taken from Azure Active Directory app manifest:
replyUrlsWithType
This multi-value property holds the list of registered redirect_uri values that Azure AD will accept as destinations when returning tokens. Each uri value should contain an associated app type value. Supported type values are: Web, InstalledClient.
Hope it helps!
I have a mobile app built on Ionic 3, using Firebase and FCM plugin to send notifications.
I have 2 problems :
The badge never appears (tested on iOs and Android) (but the notifications are working normally)
When I click on the notification, I am re-directed to my application's home page. But I would like to be re-directed on a specific page of my application. Apparently, that should be specified by changing the "activity" on the "click_action" parameter, however my app doesn't have any activity.
Thanks for your help.
Here is my code :
sendNotif(){
this.postRequest()
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'key=xxxxx:xxxx')
let options = new RequestOptions({ headers: headers });
let postParams = {
"notification": {
"title": "Mon-appli",
"body": "Nouvelle réservation",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"param1": "value1",
"param2": "value2"
},
"to": "/topics/all",
"priority": "high",
"restricted_package_name": ""
}
this.http.post("https://fcm.googleapis.com/fcm/send", postParams, options)
.subscribe(data => {
this.nb_notif = this.nb_notif +1;
}, error => {});
}
I ended up here because I have the same problem with badge as you. But I think that I can answer your number 2 problem:
The redirection has nothing to do with your notification set-up. You'll need to unsubscribe from the authentication observer.
So unsubscribe in app.component.ts from the listener as follow:
const authUnsubscribe = afAuth.authState.subscribe( user => {
if (user) {
authUnsubscribe.unsubscribe();
this.rootPage = 'HomePage';
}
else{
this.rootPage = 'LoginPage';
}
});
And for question number 1:
You'll have to add badge:1 in your notification:{..} description.
"notification": {
"title": "Mon-appli",
"body": "Nouvelle réservation",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon",
"badge":1
}
I am new in react native and I need to take information from JSON file asynchronously on change text in input field.
JSON:
{ "meta": {
"code": 200,
"api_version": "2.0.1.6.0",
"issue_date": "20160620"
},
"result": {
"total": 4,
"items": [{
"purpose_name": "Торгово-развлекательный комплекс",
"name": "Asia Park, торгово-развлекательный комплекс",
"full_name": "Алматы, Asia Park, торгово-развлекательный комплекс",
"id": "9430047374983999",
"building_name": "Asia Park, торгово-развлекательный комплекс",
"address_name": "Райымбека проспект, 514а / Саина, 516",
"type": "building"
}]
}
}
If it is a local JSON file you can just use require:
const data = require('./data.json');
console.log( data.result.items[0].purpose_name );
If it is a remote API request try fetch:
fetch('https://example.com/data.json')
.then(response => response.json())
.then(data => console.log( data.result.items[0].purpose_name ))
.catch(error => console.log(error));
If this file is local you may simply require it, it will get parsed automatically. If it is on some server you need to use the Fetch API.