Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49176

Ionic1 Push Notification by using Ionic IO Services

$
0
0

@guptarohit19 wrote:

Hi Everyone,
I know there are plenty of references already available to implement push notification from scratch. It seems simple initially but i have got stuck in between and not able to decide where is is issue in my approach to implement push notification in ionic 1.

I have used below references for building my sample app

https://devdactic.com/ionic-push-notifications-guide/

http://docs.ionic.io/services/push/

  1. I have set my GCM Project and API Key on Google Cloud
  2. I have set my security profile using the same GCM API key in Ionic IO.

I have my app running in browser which have generated and displaying the device token.

Now i am trying to send Ionic Push messages from ionic io but all the messages are going in send state and none of them status is changing.

I have even tried to publish by using a sample node js script or by using PostMan pluggin but its failing with below error :

STATUS: 401
HEADERS: {"connection":"close","server":"nginx","date":"Wed, 14 Sep 2016 03:36:5
5 GMT","content-type":"application/json; charset=utf-8","content-length":"196","
via":"1.1 vegur, 1.1 vegur","access-control-allow-credentials":"true","access-co
ntrol-allow-methods":"HEAD,GET,POST,PATCH,PUT,DELETE,OPTIONS","access-control-al
low-headers":"DNT,Authorization,X-CSRFToken,Keep-Alive,User-Agent,X-Requested-Wi
th,If-Modified-Since,Cache-Control,Content-Type"}
BODY: {"meta": {"request_id": "87cae260-72cb-4138-8737-0cb23e6d425e", "status":
401, "version": "2.0.0-beta.0"}, "error": {"type": "Unauthorized", "link": null,
"message": "JWT decode error occurred."}}

Here is the node script :

var ionicPushServer = require('ionic-push-server');

var credentials = {
IonicApplicationID : "48e8672d", // app_id
IonicApplicationAPIsecret : "9e330522a91be8a2714a52371e4b94d13a4d9a074cab8b5e" // io
};

var notification = {
"tokens":["DEV-11f90c9f-7d07-414c-aa32-7640e4ebe1a3"],
"notification":{
"alert":"Hi from Ionic Push Service!",
"android":{
"badge":1,
"sound":"chime.aiff",
"expiry": 1423238641,
"priority": 10,
"contentAvailable": true,
"payload":{
"key1":"value",
"key2":"value"
}
}
}
};
ionicPushServer(credentials, notification);

I am not sure how do i trace whether the issue is

a. between Ionic Push and GCM
b. or From GCM to My application

I want to first verify the demo in my web browser to see if i am able to publish from Ionic Push > GCM > My application (or phone)

Need any help if there is a better way to test this flow. Sorry for asking the same steps again

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49176

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>