I am using xmpp/css push implementation, all is fine at server side but I am not receiving any push on device.
So, i need to debug PhoneGap PushPlugin
Firstly please check whether device id is generated or not at Android App side by checking logs.
If generated, then-
Try to use DevHttpClient Google Chrome plugin.
In that, you need to enter
Request URL : android.googleapis.com/gcm/send
Content-Type : application/x-www-form-urlencoded
Authorization : key=API_KEY
And in body :
{
"registration_ids":["XXX Device ID XXX"],
"data":{"message":"Push Notification Test"}
}
You can check this image:
Related
I have an ionic app that when I run that on iOS then it works perfectly fine but when I run that on Android I get this error
Http failure response for (unknown url): 0 Unknown Error
Any reason I am getting this one? I have allowed CORS on server side as it is working on iOS devices.
Any help?
EDIT
This is what I have in my app.js file
const cors = require('cors');
And then I simply use it with default options.
app.use(cors());
If you are using localhost, change it to the IP address of the localhost. Android doesn't seems to support it where iOS do.
Try actual host name in case it didn't work too.
First you dont need CORS to call API from your android device.
Second probably your server is not accepting your request. If you are using Cloud then your server must accept request from any IP. There must be a option for allow IP address, place there from 0.0.0.1 to 254.254.254.254 so that each and every user can call your API.
Third you need to allow origin from your config.xml and also in header for CROS request. Check your API header and config file.
And fourth If your service is running under http then it will also could be the problem. Secure your service by adding SSL certificate. This could fix your problem.
We had experienced the same Error several times in our App. In our case it was a problem with the headers of the request and also a CORS problem on the serverside.
Are you able to reproduce this error in the browser if you emulate a android device? Then you could compare them with the headers of the iOS request.
Or you can try to log the incoming requests on the server-side to see if the requests reach the server and what headers are set.
Hope my ideas help :)
The solution is to add NODE_TLS_REJECT_UNAUTHORIZED=0 to your environment to disable the SSL verification in Node.js.
Note : You should only set this in development, Don't do this in production
EDIT
In that case it indicates that CORS has not been properly setup on your server. Go through the issue here
This is complicated but I'll try to be as concise as possible. I am using FCM to send push notifications to Android devices. My backend is parse server. I can successfully send pushes from the FCM console to the device. And when I send pushes from parse to https://mybackend/parse/push, it says {"result": "true" } as the response. I have checked the server logs, and it (predictably) says all http post requests to /parse/push were 200 success.
However when sending from parse (using curl or the parse push console), the pushes do NOT show up in FCM console. There is some issue between parse server and FCM then.
In my index.js, I have:
push: {
android: {
senderId: "XXXXX",
apiKey: "YYYYYY"
}
}
I have the keys, and done everything according to here: http://parseplatform.org/docs/parse-server/guide/#push-notifications
what else am I missing? Why can't I get this to actually appear on the device? Any help is greatly appreciated, thanks.
Setting up a Parse Server for an Android app, I remember having to double check this to get it right. The key for me was this: when I logged into Firebase console and selected the app I was working on, and clicked on the gear [or cog or whatever] and then Project Settings, I had to make sure to click on the Cloud Messaging tab and grab the Legacy server key [under project credentials] NOT the web api key that appears on the General tab. Also the sender ID that you want to use appears on that page.
I'm not sure when they will deprecate the Legacy server key, you might try the Server key instead, but definitely make sure you get the info off of the Cloud Messaging tab.
I don't know why FCM (and APNs) don't send a different message when the key (or cert) is not set up right [that would be more developer-friendly at least] and instead just send a 200 but my guess is that they evaluate the key [or cert] after receiving the intended notification and sending a response.
I'm working on Remote Notifications in my Ionic App using OneSignal.
I have created an App in OneSignal, configured it for my app and initiated the service as per the Official Docs.
To test this, I am using Postman Chrome Extension. So, after adding the POST Request URL, where can I find the String values for the include_player_ids key.
I have my app still in testing state.
What's the code in typescript to get the value of include_player_ids from our Mobile Device?
Assuming you are using the OneSignal Native Android SDK, you should use the OneSignal idsAvailable method to get the device's OneSignal Player Id and then pass this value to your server.
window.plugins.OneSignal.getIds(function(ids) {
console.log('getIds: ' , ids);
self.deviceToken = ids.pushToken;
self.userId = ids.userId;
console.log(self.userId);
});
That gives u deviceToken and OneSignal User ID, which is referred to as Player ID
I copied the value from the console and used!
Thanks #Saiy2k
I've started working with push notification, and everything works fine while using dev_push=true.
However, when I set dev_push=false, I can't get it work.
The weird thing is that it seems like my device is not recognized correctly. In the chrome console this log appear twice: $ionicPush:REGISTERED *token-value*.
I registered to the $cordovaPush:tokenReceived event, like this:
$rootScope.$on('$cordovaPush:tokenReceived', function(event, data) {
console.debug('Ionic Push: Got token ', data.token, data.platform);
});
and I saw that the event is sent twice - once with platform ios and once with android,
When I sent a one time notification from the ionic dashboard, nothing happened. Checking the message status gave this:
{"app_id":"4f0867d9","status":"Failed","ios":{"sent":0,"success":false,"failure_reason":"Push Error Code 302: See http://docs.ionic.io/docs/push-error-codes for more info."},"errors":[]}
Anyone knows what could be the problem and how to fix it?
if it is not working frome there try using POSTMAN
how to use postman
POSTMAN
//to test wether your configure correctly with ionic io open launch postman
//and then do the following things:
1-create collection give it a valid name
2-in body click on text and select Application/json
it will add header automatically
3-add another header
key as Authorization
value as Bearer followed by your api token from ionic io
4-select "raw " as the format of our json
2-in body section of your collection write
following code
{
"tokens": ["DEV_DEVICE_TOKEN"],
"profile": "PROFILE_NAME",
"notification":
{
"message": "This is my demo push!"
}
}
I am working on an android app that will recieve push notifications from the GCM server.
I am using php as the 3rd-party server.
I've a few questions.
When I send request to gcm server from my php script it gives me the following response
{"multicast_id":8799227316277290616,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1341388064110557%5d17b789f9fd7ecd"}]}
Now the response seems fine but you can see a % sign in the message_id. Is that ok? if it's not than how am I able to recieve the correct message_ID?
When I use json_decode in my php script and echo this multicastid it gives me something like this
8.7992273162773E+18
and I am sure it will give the same type of value when I'll echo message_id also. So why it is not echoing the correct value?
My last question is that when I send this request which seems right and open my android application there is no notification there. Is it caused by the above errors or there is some other problem?
I had a similar issue with C2DM. The reason was that the android app name was not the same for which I requested the quota. It got fixed once the corrected the package name.
In my case, android application was not running so the push notifications can't be received. I started the app and then I could receive messages.