Pushwoosh - no subscribers are added in android - android

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.

Related

Getting allegedly randomly "No permission to send message to these tmIDs" HMS Push services

🟢 Fixed server-side
Note: this was a server side bug and for now seems to be solved. Our mobile app code remains unchanged.
I have to use HMS Push Services in order to make my RN App working for Huawei EMUI devices: HMS Core.
I followed all the required steps to install and configure HMS both on the server and on the mobile App.
However... I noticed a weird behavior. I use a button on the web page to send a Push Notification from the server to the Mobile App. I ensured that Push Kit is enabled on my Huawei ID and the Push Device Token is the correct one.
Sometimes the notification is sent and sometimes no. I tried all the day to find the cause, but for now it seems to be completely aleatory, at least until the cause will be not found.
Please note that in the code below the mc.send() goes every times into the .then() and never raised the .catch().
Sometimes I get: OK {"code":"80000000","msg":"Success","requestId":"161832746491754926000107"} and the notification is actually received from the Mobile App (all fine!).
Sometimes (and quite often): OK {"code":"80300002","msg":"No permission to send message to these tmIDs","requestId":"161832753512250325000107"}
Lastly, I am getting continuously: OK {"code":"80000000","msg":"Success","requestId":"161832795126307445060711"} but... the App does not receives actually the notification.
I tried to restart server, keep the App in the three various States (closed, foreground, background), but nothing helped me to find the problem.
This is the last version of the code I use to send the notification (I changed it many times):
function sendPushNotificationHMS(pushDeviceToken, data, attempt){
hcm.init({
appId: configHMS.AppId,
appSecret: configHMS.AppSecret,
authUrl: configHMS.AuthUrl,
pushUrl: configHMS.PushUrl
});
let mc = hcm.messaging().messaging;
let androidConfig = {
collapse_key: -1,
urgency:"HIGH",
ttl: "10000s",
bi_tag: "the_sample_bi_tag_for_receipt_service",
}
let message = {
data: JSON.stringify(data),
android: androidConfig,
token: new Array(pushDeviceToken)
};
mc.send(message, true).then(data => {
console.log('OK ', data);
}).catch(err => {
console.log('ERR ', err);
});
}
Please refer to this documentation:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/commonerror-0000001059816656
and see if one of the solution under 80300002 is correct. Since you have checked if your IDs are correct, please check the tips under 2, 4, 6, and 7.

FCM push notifications with Parse Server

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.

FCM Notification is not working If i send it by using ARC ( Advanced REST API )

I integrated the push notification system with Firebase in my project and it's working well except one thing.
If I try to send a notification from Firebase console, using Device Token & Topic, the notification shows in device.
If I try to send a notification from ARC ( Advance REST CLIENT) using Device Token, the notification shows in device.
If I try to send a notification from ARC ( Advance REST CLIENT) using my topic, NOTHING HAPPENS.
Requested URL : https://fcm.googleapis.com/fcm/send
RAW headers :
Content-Type: application/json
Authorization: key=AIz.....
RAW PAYLOAD :
{
"data":
{
"employeename":"kumaran","empid":"234444"
},
"to":"/topics/bmmembers"
}
Response Header
Status : 200: OK
JSON :
{
"message_id": 6536474446058224000
}
But my device not received any notification and checked Logcat whether any json arrived in client end, but not received.
Any idea and how we need to resolve this issues.
This is my trial and error type of a "Solution found for this Issue":-
Issue found is "The Quota for the particular Server-key or credential or the whole Google API Account itself might have been expired or used the limit. "
Below i have explained how i once again successfully received FCM Notifiaction with Image for the same Android App.
ISSUE:-
I was unable to send FCM push notification (with image) from Advanced REST Client, by using the Android key generated from Google API console in my very old created Project (Eg: My Project; that has 5-apps and its credentials).
I tried sending the Post request from ARC client many time but dint receive any single FCM notification in my Android Mobile.
SOLUTION I FOUND WAS:-
1a. I deleted the credentials (API key, server key,web key, OAuth key etc) in Google API console related to that particular app (Eg: FCM App1).
1b. Also i went to Firebase console and deleted the particular app in its project also.
Finally now the App (Eg.FCM App1) doesn't contain connection with
1.Google API console and with
2.Firebase Console.
1c. I also deleted the "google-services.json" file from the Android studio->Project folder.(If you are unable to delete this, try executing File->'Invalidate cache and restart' option and then retry deleting it. It will get deleted.)
Next, freshly
I created a new gmail account, and opened a new Google API Account, further opened a fresh new Project in that Google API Account (Eg: My Project1).
Next, I went to Firebase console signing in with this newly created Gmail acccount, opened a fresh new Project, selected "Add App" and selected "Android".
-> entered my package name, SHA1 key and Added the App.
-> Also downloadedthe new google-services.json file and added again in the Project folder in Android Studio.
-> And followed everything as per previous procedure.
==> Finally I got the fresh ""Server-Key"" in the new Google API console. Copied this server-key and pasted in Advanced REST client at place Authorization:key=AIzaSyAJzs-DDD......etc.
=> added the correct TokenID freshly created for this App from Log.
===> Pressed SEND button in the ARC, and WOOOOWWWW....
within few seconds I GOT THE FCM NOTIFICATION WITH IMAGE IN MY ANDROID MOBILE EVENTHOUGH MY APP WAS IN BACKGROUND OR COMPLETELY CLOSED at that time....!!!

Ionic push notification not working on android device

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!"
}
}

Correctly formatting GCM notifications?

I'm currently trying out the google cloud messaging service with its sample application "Guestbook." https://developers.google.com/cloud/samples/mbs/
I'm attempting to send notifications that should appear as a simple "hello" toast on screen for about 5 seconds.Doing this from the project settings page (pictured here)works.Perhaps i've misinterpreted what this for.
However my attempts to do it manually via fiddler2 cause the guestbook client application to crash instead of making the intended toast flash up onscreen.
Here is an example of the POST request i used to attempt a push notification
I have also done other variations of the above where i have included "topicId:_broadcast" to no avail.
Is there something in the formatting that i have wrong? or missing information i should have included.
You got the format a bit wrong. It should be :
{
"registration_ids":["xxx", "yyy"],
"data": {
"message": "test",
"duration": "5"
}
}

Categories

Resources