Ionic - Push notification

See https://forum.ionicframework.com/t/ionic-2-push-notification/53898/18?u=ankushagg93. Also, if you can show your app.ts code, it will help in debugging as it’s impossible to tell error in code without seeing code itself :grin:

I’ve created a git repo for push notification demo

https://github.com/aggarwalankush/ionic2-push-base

Also, server code to push notification

https://github.com/aggarwalankush/push-notification-server

2 Likes

thanks @ankushagg93,
I am new to ionic, I think you are using


to send a push message to devise!!!

can’t we do this same uisng thinrd party service as

I also don’t know how to use this because it seems java code.

Device token how i send to server in ionic v2
i got errors that code mention here , please Tell me to how i send device token to Server (Post method) Please attach the code
----------------------------------------Post Moethod is it Right or Wrong ? -----------------
In Constructor
http: Http;
data = “”;

user = {“YOUR_DEVICE_TOKEN”:""+data.registrationId};
console.log(JSON.stringify(user));

this.http.post(‘http://192.168.1.39:8081/controler/ionic2notification’, user)
.map(res => res.json())

         .subscribe( obj => {
          console.log(JSON.stringify(obj)) ,
          this.data = obj;
            alert(this.data.status)


         },

         error => {
           alert("network error")
          //console.log(JSON.stringify(error.json()));
          return false;
      })

There are many ways to write server code, I just gave a sample in Java. You just need device token and api key to push.

You don’t need to send token to server, in my code it’s a comment. When you will run you app, you will see device token in console, just note it down and use for push notification. If you want you can use my AndroidPush.java code to push. Also, if you just follow readme file in my repo without any code changes, push notifications will work and over attached screenshots also

my server application is a web application if i want to send a push notification to the mobile app should my web application has to register with gcm or not. As the given url is a http protocol I directly sent a request to send push notification it is giving 200 as status but the mobile app is not receiving the notification. So please solve this.

Hi,

I got the basic push notification working. But when the app is closed, i don’t get the notifications on my android device. Any idea how to solve that?

Thanks
Kousik

Hi Ankush,

I am using Ionic 2 push notification with angular.

I could generate the device token, but I can’t figure out how to handle notifications. The code provided on the ionic site doesn’t seem to be working.

Could you please tell me how did you handle notifications?

See if this is useful Ionic Push Notification - Android and iOS working

Thank you for your prompt response.

Since I am using angular, I don’t know where do I import the Push class.

Hello guys

I am just start to play around ionic push once i send push from ionic Dashboard i receive that push in app but once i try to access it through Rest API using angular 2/ nodejs then i got this output

{"meta": {"version": "2.0.0-beta.0", "request_id": "05e88386-f405-4acf-cadf-33063df787c2", "status": 201}, "data": {"status": "open", "state": "enqueued", "config": {"profile": "demo", "notification": {"message": "Hello World!"}, "tokens": ["djObsfRcV_Y:APA91bEj_8LNlUMGVou9CzfEwTvwfain3vC9ckGMUT98T2g8t0G__eu_wpoZWbzSSFssXK4v2mOWtxa6csU8HjvSBQhY1eqoYJZpxXsKjw6EZDeV5bdRP2NHCYf2sCrHhPCifg_V39Qo"]}, "uuid": "2001a2a3-2095-4729-8c20-d03a62c6b785", "created": "2017-03-02T12:22:49.537210+00:00", "app_id": "053e90c2"}}

But i didn’t able to receive push on my app.

Can you please help me out what exactly the issue.

Thanks.

Can you please explain,How to run or use server code in ionic 2??
with sample

Running instructions are mentioned here https://github.com/aggarwalankush/push-notification-server#push-notification-server

i followed your tutorial from your blog tphangout and i am having an error saying “Error subscribing for Push notifications.”.
provide me solution please.

Could you please follow the instructions here - http://tphangout.com/ionic-2-push-notifications-with-firebase/

Can some please advise on the following:

Hello, i followed your tutorial and i have recieved push notification in my app. I just want to show badge on app icon when app is close and push notification arrives. Please help Thankyou :slight_smile:

Is there a way to split up the logic of my this.pushObject.on(‘notification’) - listeners? I am working with Tabs and want the specific page to get the corresponding notification. Currently I am just injecting Push into my TabsPage, creating the pushObject there and thus won’t have access to it from the specific tabs. So if a friend sends me a message, I want my FriendListPage to handle that, so I can show some visuals to highlight the new event. Is making the PushObject static an option ?

Hi@rajayogan I have couchebase lite qnd sync_gateway and couchbase lite on my ionic app. How do i manage the push notification to notify the app device when the sync_gateway get a specific data from couchbase server.

Thanks for advance.