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!"
}
}
Related
I am migrating from custom Push Notification to AWS SNS. I did the following.
configured AWS SNS Topic
Created Platform Application
created Endpoints
Suscribed endpoints to Platform Application
I am trying the last step for Pushing the Notification using 'publish' API for Ruby. I receive the message_id as response. It also logs as success / delivered in CloudWatch. But the Push is not received in the device.
The device is valid
The device has a valid push token
the device has the application installed.
The message format I tried areas follows
{"GCM"=>{"data"=>"{\"message\":\"message\",\"url\":\"url\"}"}, :default=>"default"}
SNS publish API syntax
client.publish({target_arn: endpoint_arn, message: message.to_json, subject: "SNS test", message_structure: :json})
FYI, Before marking this as duplicate of any other question, please note that i have referred all previous answers and nothing helped me. hence I am raising a new one.
The GCM payload format is updated.
This works for me.
{
"GCM": "{ \"notification\": { \"body\": \"hello....\", \"title\": \"title123\" } }"
}
There is a problem with my message formation. I figured it out by debugging with android . The Push reached the device but it was not in the expected format. So the push was not shown in the device. I was sending
{"GCM"=>{"data"=>"{\"message\":\"message\",\"url\":\"url\"}"}, :default=>"default"}
But the Android system was expecting 'badge' and some other keys in my message. I tried with
{:default=>"default", :GCM=>"{\"data\":{\"message\":\"test\",\"url\":\"https://s3.amazonaws.com/mcds_fulltext/aapg/gsaapgbull/issues/74/android_hdpi/cover_74.gif\",\"registration_ids\":\"arn:aws:sns:us-****-1:*********7:endpoint/GCM/gs*****_gcm/*********************\",\"badge\":\"10\",\"vol\":\"128\",\"issue\":\"10\",\"journal_name\":\"gsaapg\",\"abbr\":\"aapg\"},\"collapse_key\":\"New Article badge\"}"}
Now it works as expected.
This particular JSON might not be appropriate for everyone. But the cause of this issue is the message JSON is not in the expected format for the mobile app. This might be helpful for someone who face the similar issue.
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 am trying to add new subscriber with pushwoosh remote api services.
RegisterDevice
POST https://cp.pushwoosh.com/json/1.3/registerDevice
{
"request": {
"application": "XXXX-XXXX", // THE PROJECT ID ON PUSHWOOSH
"push_token": "APA........", // GOOGLE DEVICE REGISTRATION KEY
"language": "en",
"hwid": "YYYYYYYYY", //UUID
"device_type": 3 //ANDROID
}
}
// RESULT 200 - OK
My app works perfectly fine.
when i check my pushwoosh control panel i see subscribers
but the Android platform shows no subscribers.
I cross checked the project id , server key... and everything fine.
what am i doing wrong?
Check the server response. It should be 200 and status code is "ok".
Sometimes when the Cloud is super busy it might take a minute or two for the devices to appear.
I am building an Ionic app with VS2015 (cordova/phonegap), and using the push notification plugin. There is no problem in the actual functionality of the push notifications, I get them correctly and they are displayed to our customers.
What I am trying to do is to get the title and/or id from the payload of the notification.
The registration code is as follows:
var template = '{ "data" : {"message":"$(message)", "id": "$(id)", "title": "$(title)"}}';
// Register for
mobileServiceClient.push.gcm.registerTemplate(e.regid,"CT2", template, NOTIFICATION_TAGS_ARRAY)
When I try to access the notification (in function onGCMNotification(e)) I can only see the message and all other params in the payload are undefined (if I try accessing e.payload.id)
Can anyone help me?
Note: I am using the phonegap push plugin - not the Ionic one.
UPDATE:
I finally got it to work once, but just for the first notification - so we still have the problem.
What happened was as following:
I uninstalled the app and re-installed it.
Re-registered my custom template.
Results are that I get the notification twice:
First time - payload contains only message (not other attributes)
Second time - I get the complete payload with extra attributes.
Next time we send a notification and any other time - we get only the message in the payload without the rest of the attributes.
Cordova version 5.1.1
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: