简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM