ionic-team / legacy-ionic-cloud

JavaScript Client for legacy Ionic Cloud services. See Ionic Pro for our new take on the ionic development lifecycle
Apache License 2.0
65 stars 26 forks source link

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

Open jgw96 opened 7 years ago

jgw96 commented 7 years ago

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: driftyco/ionic#11746

danielolivaresd commented 7 years ago

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.

danielolivaresd commented 7 years ago

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

Gurjit-ONEBCG commented 7 years ago

@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?

danielolivaresd commented 7 years ago

Yes. I can receive notifications now

On May 24, 2017 10:42 PM, Gurjit-ONEBCG notifications@github.com wrote:

@K1N5L4Y3Rhttps://github.com/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?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/driftyco/ionic-cloud/issues/212#issuecomment-303914298, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB_rPc95CziH5fw6yKpzR_30z6eT6b3eks5r9PibgaJpZM4Nidz1.

Gurjit-ONEBCG commented 7 years ago

@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 ?

danielolivaresd commented 7 years ago

As mentioned, I was not able to receive push notifications until I performed the steps I mentioned (manually configuring the capabilities in Xcode)

On May 25, 2017 10:17 PM, Gurjit-ONEBCG notifications@github.com wrote:

@K1N5L4Y3Rhttps://github.com/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 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/driftyco/ionic-cloud/issues/212#issuecomment-304180509, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB_rPbQnqwboGWo58UDwxMGLG17cN215ks5r9kRXgaJpZM4Nidz1.

Gurjit-ONEBCG commented 7 years ago

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

revetevra commented 7 years ago

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

Gurjit-ONEBCG commented 7 years ago

@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 .

Blackscr33n commented 7 years ago

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

Gurjit-ONEBCG commented 7 years ago

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

Blackscr33n commented 7 years ago

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

gladiacxtylish commented 7 years ago

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?

nadouani commented 7 years ago

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

Blackscr33n commented 7 years ago

Because I get the Notification displayed @gladiacxtylish

shuhanxu commented 7 years ago

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)?

manojsingh047 commented 7 years ago

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

Gurjit-ONEBCG commented 7 years ago

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

kanak-infoObjects commented 6 years ago

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

Gurjit-ONEBCG commented 6 years ago

@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

kanak-infoObjects commented 6 years ago

"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

Gurjit-ONEBCG commented 6 years ago

@kanak-infoObjects Old one can work

kanak-infoObjects commented 6 years ago

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

Gurjit-ONEBCG commented 6 years ago

@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.

kanak-infoObjects commented 6 years ago

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

Gurjit-ONEBCG commented 6 years ago

@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

wf-intergy commented 6 years ago

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