ionic-team/legacy-ionic-cloud

Push notification in iOS not working using IONIC 2 cordova phonegap push plugin

Opened this issue ยท 27 comments

jgw96 commented

From @Gurjit-ONEBCG on May 22, 2017 6:23

Ionic version:
2.23

Cordova version
7.0.1

I'm submitting an issue which is related to IONIC PUSH NOTIFICATION using cordova phonegap plugin

Current behavior:
In android working fine eg. getting push notification. But in iOS do not get the notification, but in alert I see the generated token.

Expected behavior:
iOS devices should get the notification as well

Related code:

export class MyApp {
  rootPage = HomePage;
 
  constructor(platform: Platform, public push: Push) {
    platform.ready().then(() => {
      StatusBar.styleDefault();
      Splashscreen.hide();
 
      this.push.register().then((t: PushToken) => {
        return this.push.saveToken(t);
      }).then((t: PushToken) => {
       alert('Token saved:'+t.token);
      });
 
      this.push.rx.notification()
      .subscribe((msg) => {
        console.log('I received awesome push: ' + msg);
      });
    });
  }
}

Other information:
I believe I have properly created security certificates which I have uploaded to app.ionic profiles
and all other steps followed very carefully.

Copied from original issue: ionic-team/ionic-framework#11746

Same here, for some time I haven't been able to receive push notifications. I'm building my app via Ionic Package, so I'm suspecting that maybe Ionic Package doesn't perform the XCode configuration described in http://docs.ionic.io/services/push/#faq
Probably a month ago I didn't have problems with this, but in the last weeks I just can't seem to receive them in iOS (while Android works). I even created security profiles again, just to make sure.

Update: I manually built for iOS on a Mac, and first the Push Notifications Capability (refer to my previous comment) was indeed OFF. After setting up my Apple ID, and dev. Team and restarting Xcode, the capability was ON. I think this happens by default now for subsequent builds

@K1N5L4Y3R so it means IONIC push notification can be fail if I want to send urgent notification on specific time. Any how did you start receiving push notification in iOS devices?

@K1N5L4Y3R Can you please tell me that, is it true that we can not receive push notification on iOS devices which are not registered on our ituneaccount ?

I followed that in Xcode. After sending push from iclould I didn't receive any push.

Hi, I have the same issue, can anyone please explain how he solved it?
Thanks!

@revetevra I moved with this [https://www.djamware.com/post/58a1378480aca7386754130a/ionic-2-fcm-push-notification]
It worked fine for me.
Important: Use Auth certification(p8) instead p12 ssl .

I am reciving Push-Notifications but the event
this.push.rx.notification().subscribe((data) => {...} never gets fired.

And I don't know how to debug this because I can't access the logs of the App while in Prod-mode

@Blackscr33n As it fires only one we click on push notification. You can use alert(data) under subscribe of notificaiton() to test

I know that I can do this. But this event never gets fired. That was what I mean with never gets fired

We are also hitting the same issue here. Local build works fine, ionic package build does not work.
@Blackscr33n How do you tell you are receiving notification?

Hi everyone, I was facing a lot of push issues on iOS, and trying the find the root cause was frustrating.
My advice is to make sure that your iOS device really receives the pus notifications. Once you confirm that push are correctly sent to your device, you can debug your Ionic code.

I use that tool to send the push notification https://github.com/noodlewerk/NWPusher and I honestly thank the guy who produced NWPusher

Because I get the Notification displayed @gladiacxtylish

From https://docs.ionic.io/services/push/
""
Note for users of Xcode 8 and higher.

If you're using the latest version of Xcode, you will likely need to activate the Push Notifications capability before your app is able to receive notifications.

To do this, simply navigate to the Capabilities section in your app's overview within Xcode and toggle Push Notifications, as seen below.
""

But how can I switch on push notification capabilities section in ionic package build (cloud build)?

@Blackscr33n -- Did you find any solution? I am also stuck on the same issue.

Use FCM, it worked for me. I can guide you if you stuck while using FCM

I have implemented FCM in my ionic2 app. It is working very fine for android. But I am not able to get notification in IOS.
Can anyone please guide me through IOS process.
@Gurjit-ONEBCG @jgw96 @K1N5L4Y3R @revetevra

@kanak-infoObjects do followings
Generate auth key in your itune developer account
configure iOS settings in your project of FCM console
download googleservice info plist file. keep it in resource folder of ios project
check then

"Generate auth key in your itune developer account"
I was using puch notification services for my app previously. It was working fine. Now I need to switch to fcm.
So do I need to generate("auth key in your itune developer account") it again or old one can work ??
@Gurjit-ONEBCG

@kanak-infoObjects
Old one can work

Still not working. Do I need to make any specific changes for IOS because android is working very fine for me.
@Gurjit-ONEBCG

@kanak-infoObjects follow this tutorial
https://www.djamware.com/post/58a1378480aca7386754130a/ionic-2-fcm-push-notification

Instead of .p12 use auth key in FCM console

Let me know if you are still get stucked somewhere.

Thanks for the tutorial. It worked for me.

I have been trying a lot to schedule local notification in case of app in foreground by using "cordova-plugin-local-notifications" its working fine in android but it is not working for ios again can you please help how to do it ??
@Gurjit-ONEBCG

@kanak-infoObjects
The notification is mean to come when the app is in background or terminatted(not opened).
However, do you get local notification if the app is in background?
Share your code please

Thanks for your detailed tutorial, we have followed the same steps what is mentioned in the link except heading 4 as we are using node.js for sending push notification instead of ionic.
https://www.djamware.com/post/58a1378480aca7386754130a/ionic-2-fcm-push-notification

When we trigger notification from the application and FCM console, we are able to receive it for android but for ios its not receiving. We are able to retrieve the FCM token for ios and the permission has enabled but its not working.

Could you help me how to fix the issue?

Thanks