React-native-push-notification: PushNotification.localNotification not working on ios10

Created on 9 Sep 2016  路  32Comments  路  Source: zo0r/react-native-push-notification

Most helpful comment

You will not see a notification if the app is in the foreground on iOS. That is expected behaviour.

All 32 comments

Can you provide more detail?

@sibelius It works for me in iOS 10 with "react-native-push-notification": "2.1.0"

I'll try to update it, I'm using 2.0.2 tks

This code do not show a local notification on ios 10, I'm using xcode 8, RN33, RNPN: 2.1.0

PushNotification.localNotification({
        message: "my local push",
      });

it works fine on android

Are there any error messages?

There are no error, this happens when my is in foreground, could this be the problem?

Same here, any solutions?

OK, for my case, the problem was not setting header search path _RECURSIVE_

I'm not having any issues with iOS 10, RN 0.33 and RNPN 2.1.1 so far.

I've got the header set to recursive, but local notifications not working. Scheduled notifications work fine though. Very odd.....

@steve-gray did you set listeners for 'notification' ?

@edencakir which listeners are u talking about? Could u post some code?

In component will mount: PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification);

class method:
_onLocalNotification(notification){ console.log(notification); AlertIOS.alert( 'Time to practice!', notification.getMessage(), [{ text: 'Dismiss', onPress: null, }] ); }

EDIT: Use listeners in docs instead.

var PushNotification = require('react-native-push-notification'); PushNotification.configure({ ... onNotification: function(notification) { console.log( 'NOTIFICATION:', notification ); }, ... });

You are using PushNotificationIOS? That's all _wrapped_ by this project, you shouldn't need to use it directly.

@npomfret Ah yes I know, sorry for misleading, that was for testing React Native docs notifications. Developers should follow Usage section of Readme.md document. Thanks for the heads up!

Any solutions to this?

Displays perfectly on ios 9.3, but doesn't display on ios 10.0

this could help this package as well: https://github.com/evollu/react-native-fcm/issues/117#issue-178342730

@Brockify can you please give as much detail as possible. I can confirm that this project works on iOS 10 as well as 9, but there's are so many places it could go wrong it's difficult to diagnose issues without detail.

The most common problems are:

  • it's not linked correctly - the RCTPushNotification project is missing from Xcode, or the binary isn't linked.
  • the capabilities aren't set up correctly in Xcode
  • the remote push notifications being sent aren't in the correct format
  • it doesn't work at all in an iOS simulator, you have to test on physical devices

encountering the same issue on physical device, put a log on didReceiveLocalNotification, i can see the notification. there is no error thrown, but still can't see the notification on the device. works great on android though. still trying to find out the solution for this.

set the capabilities accordingly as well.

Ah, please ignore me. I just read another thread that the notification in ios will only be shown when it's running at foreground. Was expecting it to behave the same way as android. Sorry for the false alarm

@sibelius have you resolved your issue? Can we close this?

yep

I'm having this issue currently. I am trying to fire a local notification and I see can that onNotification is being called and the notification data is being logged to the console via:

onNotification: notification => {
    console.log('NOTIFICATION:', notification);
},

but no actual notification is fired. This happens both when the app is foregrounded and backgrounded. And actually, the console doesn't log until I come back into the app because (I'm assuming) the js thread is paused while in the background. Any thoughts?

same problem :((

anybody got solution?

@Swapnilchavan18 @felangga I think different people have had different issues in the code due to which the notification were not showing up on the phone. Unless you share more information about your specific use case, how you are scheduling the notification, how have you tried to debug the problem, are you seeing any error logs etc., I doubt if anyone can help resolve the problem.

Oh sorry it worked when app is in background but did not worked when app is in foreground.

You will not see a notification if the app is in the foreground on iOS. That is expected behaviour.

ok Thanks. @varungupta85

same thing

@varungupta85 Could you please give some detail about this?
(link or something.. I would like to see and understand what are expected behaviours in ios)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Benzer1406 picture Benzer1406  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

ssolida picture ssolida  路  3Comments

cookienawer picture cookienawer  路  3Comments

nguyenvanphuc2203 picture nguyenvanphuc2203  路  3Comments