Simple Question: Can a device recive a push message when the app is not running (native push) with ionic push service?

Allright then … I will use the phonegap-push-plugin. But the event handler “onRegister” doesn’t fire up after calling new Ionic.Push(...).register(...);

Allthough see: https://forum.ionicframework.com/t/ionic-push-in-production/38841/3?u=happyhappyjoyjoy

EDIT: It fires up now!

It should only fire if the register is actually successful. So if you get a token, it also fires.

Okay … I was asking because I got no response nor fire of event handler the last two days. I was wondering why?

?

You get a token the first time, you save it, you’re done. No more firing, no more tokens - you use the one you got the first time.

Nope. After calling the .register-method an event handler “onRegister” should fire up. The param of that handler should be the pushToken.

No event firing … no pushToken. So I could have kept waiting for the event or … or asked here what’s going on :wink:

In Android everything works. For me in iOS, when the app is active, it works. When in the background - it works. When I shut-down the app - I don’t get any push notifications to my device. Anyone knows why??

You’re still in Debug mode. Prepare for native pushs (still coming from Ionic.io) and everything will work. You’ll need to get some Tokens and Ids by the develop center of Apple and Google (for iOS and Android).
https://developer.apple.com/
https://console.cloud.google.com/home/dashboard

I didn’t understand your answer.
I don’t think I am in debug mode. I used ionic to upload the certificates…
How do I check if I’m in “debug” mode?

If you receive messages you configured everything (mostly) fine. If you ONLY receive messages when your app is running you are in debug mode. If you receive (native) messages when your app is not running you’ve all done what’s to do.

Umm … and sorry, it’s not called “debug mode” … it’s the development mode. Look: http://docs.ionic.io/docs/push-development-mode

Thanks.
Anyhow, I switched my server side to work directly with APNS + GCM and my client side to use the Cordova push plugin, and everything works well now…

My recommendation to the Ionic team -> After sending a push to ionic.io servers, in the response message, say if it was a real push or a development push… That’s important for debugging and detecting errors…

1 Like

Awesome! Our customer didn’t wanted to use Ionic.io services in his app. So I switched to Pushwoosh. Customer again said to not use this service, too, because it’s “too expensive”. Now I’m struggling with the ngCordova Push Notifications Plugin, which is deprecated.
See … https://github.com/phonegap-build/PushPlugin

The newer project on https://github.com/phonegap/phonegap-plugin-push which is used for the Ionic.io web client could be build on iOS in the past. Now I get error code 65 on each run/build on iOS. So this plugin for me is shot, too.

What’s left is the deprecated plugin above: Again … https://github.com/phonegap-build/PushPlugin

How did you configured the client side / the app? Like … Googe project number, Apple Certifactes etc.?
Did you still follow the tutorials on http://docs.ionic.io/v1.0/docs/push-android-setup and http://docs.ionic.io/docs/push-ios-setup WITHOUT using the Ionic web client? Or how did you do it?

For GCM I have allready a server api key and a project id. For APNS I have allready that certificates. What to do next after installing the plugin (and writing the js for registering)?

I know it’s deprecated, but it still works for now …

See the examples
http://ngcordova.com/docs/plugins/pushNotifications/

The new one also did not build so I used the deprecated for now. Still have to investigate why it did not build.

The plugin only deals with register (getting the devicetoken) , unregister and api calls on notification. You still need a platform to actually register the devicetoken to the right notification provider. Some uses pushwoosh. I have used AWS SNS Mobile push wich works fine.

so, what final solution did you get ? I am stuck almost in same situation as you, I do not want to use PooshWoosh because its expensive for my client, I do not know how to use Parse with Ionic and finally IonicPush , whats the deal about it ? did you finally get iOS solution ?

For my client we used AWS SNS Mobile push with

Works like a charm on IOS and Android

@coreelements
Plugin seems deprecated, should I still use it ?
If I am using it AWS SNS is not required , right ? is there any specific plugin for AWS SNS too ?

I know its deprecated … but the new one did not compile so yeah … :smile:

I have not seen a plugin specific for AWS … but AWS also requires your own server with a registration/deregistration script … your script just pushes the devicetokens to AWS and AWS will register/deregister to Apple/Google.

@coreelements
thank you very much, so I try


but I found github difficult for ionic , though I have installed it in my app dest. folder, I do not know how to use it properly, would you pls recommend a step by step tutorial etc. for me. ?

Hi there,

I just wanted to confirm that http://ngcordova.com/docs/plugins/pushNotifications/ builds and runs charming. I use GCM and APNS both with this plugin.

On Apple developer center create an **AppId **matching to the Id of your project (see config.xml, second line “widget”) and the Apple Push Notification service SSL Certificates. After that at the end you need the cert file (.cer), the private key (.p12) and its password. Configure your server with this infos.

On Google console create an AppId. Activate the Push-Notifications-Api. Create a server api key. The project number is for your register method in the app script. The server api key is for your server side and will be inserted into the payload of your push notification message.

Configuration-JSONs in the app script are …
… for APNS: var iosConfig = { "badge": true, "sound": true, "alert": true }; $cordovaPush.register(iosConfig);, get device token from this promise result.
… for GCM: var androidConfig = {'senderID': 'your Google Project Number and NOT server api key'}; $cordovaPush.register(androidConfig);, get device token from the fired event.

APNS: Take care what PN-certificate you use when taking care of the requested url (Using development certificate? Then call development url api.development.push.apple.com:443. Using production certificate? Then call production url api.push.apple.com:443. You can use port 2197 either).
GCM: Just request the one and only url https://gcm-http.googleapis.com/gcm/send with the server api key in the field authorization of the payload.

Every url request with JSON-Objects in POST method!

Read more about APNS:
https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html
https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html


Read more about GCM:
https://developers.google.com/cloud-messaging/downstream … read the other parts, too. You can ignore the iOS parts.

That’s it! If you ask yourself why APNS is complicated in comparision to GCM then you’re not the only one :smile:

2 Likes

@HappyHappyJoyJoy So you connect directly to APNS/GCM? But with APNS … you need to supply the certificate right? Do you have an example how you did that?

In my case, I just let AWS to do that so I won’t expose my certificate in my Ionic project. How did you solve that?

oh wait … you use your own sever to post the message to APNS (with devicetoken) … @HappyHappyJoyJoy