I am new to ionic framework. I developing an app using ionic 2. I have a requirement to show alert message when a new message arrives. I need help to write a code to show notification/alert.
I went though ionic 2 doc about native-push.

var push = Push.init({
   android: {
       senderID: "12345679"
   ios: {
       alert: "true",
       badge: true,
       sound: 'false'
   windows: {}

But, it give error as “Push” is not defined.
Do I missed some configuration or do I need to include some cardova JavaScript file in to my index.html?

So push has not been tested out with V2 yet, so I’d hold off for now.

You have to import Push:
import {Push} from ‘ionic-native’;

also, fix the AndroidPushOptions interface in phus.d.ts:
topics to topics?

However, I would also be happy to see a demo that works with Ionic2.

@berchik not exactly the situation here.

@mohammed2raja was asking about how to get Ionic’s push library working with V2. Currently that has not been tested, so we’ll need to give it a try :smile:

1 Like

Thanks @mhartington. Is there is any way to implement it in ionic 2?

I’d hold off for now, we still need to test everything to make sure it works.

Hi @mhartington thanks for the prompt response. We built our app using Ionic v2. To our surprise most of the native calls (Push & Camera) are not going smooth and our App release is totally blocked. If you could publish the timeline for native calls support from Ionic v2 that would help us align our product strategy better.


To jump on comment, if @mhartington or someone else from the team could give a rough timeline for some of these native integrations, that would be awesome. I have my app 90% complete and loving the use of TypeScript and Angular 2, but the native integrations are blocking the release. Yes, I realize that Ionic2 is in Beta and I definitely don’t want to sound ungrateful, but I am excited to get the app out in the wild. A rough timeline, even if it slips, would be awesome!

Or if someone knows a workaround to get the device token for push notifications for uses with Amazon SES, for example, that would be helpful in the interim.

Again, thanks for all you guys are doing!

Hi @mhartington any updates on the native push support :confused:

1 Like

I manage to get it working, just install the plugin and follow the steps to configure it (you can find them in the plugin repo), I used gcm for both iOS and Android, but get iOS working has been a real headache.

Init push on app file, and ask me if you have ant doubt :slight_smile:

1 Like

As @ZiFFeL says, this is possible using the phone gap plugin.

I set it up per installation, followed the example app code ( /plugins/phonegap-plugin-push/example/www/ ), and then implemented a PHP CURL script (customised from here to fire off the Notifications (once my app was registered with the GCM I setup).

Can anyone of you (@ZiFFeL @nebrekab) help me in getting a Ionic 2 sample app for push notification. It has to contain all code samples end to end and it should work both in Android & iOS.


I would appreciate some help here.
I can’t set it up in my app (ionic2 with typescript).
Tried to install phonegap-plugin-push, using their example code from (I put this code in app.js)
But when running ionic serve, I get error TypeScript error: app/app.ts(32,18): Error TS2304: Cannot find name 'PushNotification'.
I probably missing some import command or so, I would highly appreciate if someone could post full example…

Thanks in advance!!

I do not use TypeScript in Ionic 2, but…

Did you install the plugin? e.g. via CLI:
cordova plugin add

Full install details:

That should handle all the imports, afaik.

Sure, can I wash your car too? :slight_smile:

My best advice is for you to setup the Ionic 2 sample project, and get your head round how that is working:

Then run through the install instructions and example code for the push plugin:

good luck.

Yep, that’s what I did actually.
Well, thanks, I’ll dig some further…

Currently, there is no Ionic Platform support for Ionic 2 apps so you can’t use the Ionic Push service yet.

As an alternative, I’m using a third-party push notification service named OneSignal. They have their own cordova plugin, great documentation and also a Server REST API. It’s easy to setup and works perfectly.

Thanks a lot @nunoarruda i will give a try and let you know. Our product release is stuck badly on this.

At last the thread grabbed some attention. I did try out all the examples but none of them worked for ionic 2. Hope the solution proposed by @nunoarruda works. Will keep you guys posted. Thanks guys for all the support so far. By the way, I certainly like the offer :slight_smile:

1 Like

I just got OneSignal working in a V2 TypeScript app yesterday. Only to the point of sending a Notification from their dashboard but it seems to work fine.
The key to my finally getting it to work was using this:
this.pluginObj = (<any>window).plugins.OneSignal;
Then window.plugins.OneSignal.init() as described in the OneSignal docs worked. It still showed as an error in mt editor ( VS Code ) but worked otherwise.