React-native-push-notification: iOS setup issues. Should revisit iOS documentation

Created on 24 Jul 2019  路  10Comments  路  Source: zo0r/react-native-push-notification

Right now the documentation for the iOS setup prompts to follow these instructions. https://facebook.github.io/react-native/docs/pushnotificationios.html#content

However this is both deprecated in RN core and doesnt work with the new autolinker system. Documentation should be revised to point here. https://github.com/react-native-community/react-native-push-notification-ios

A thing to note about react-native-community/react-native-push-notification-ios (at least at this point) is simply npm install doesnt work at this moment as there is an issue where you need to reference the podspec explicitly in your Podfile.

https://github.com/react-native-community/react-native-push-notification-ios/issues/11

Hope this helps someone, took multiple hours and the help of a friend to figure out.

EDIT: Going with the react-native-community version is not an approach that will work as it yields

Native module cannot be null
most likely due to an import incompatibility.

Its a little confusing on how to make this work with ^0.60

Stale

Most helpful comment

HI @GertjanReynaert - thanks for sharing. I can also confirm that the latest build works fine react-native-push-notification (3.1.8) and @react-native-community/push-notifications-ios (1.0.2.

The install instructions look like they have been updated, but for anyone coming from a previous release where they were using React-RCTPushNotification here are the steps:

Firstly, React-RCTPushNotification has been removed from the normal react package (just like ASyncStorage was) and now resides within the community. Therefore you will need to:

  1. Remove your PodFile entry for React-RCTPushNotification (your PodFile is in the ios directory): Remove this:
    pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
  2. Install the new push notification module into your project: yarn add @react-native-community/push-notifications-ios
  3. Go back to ios and runpod install
  4. Replace all entries in your AppDelegate.m for RCTPushNotificationManager with RNCPushNotificationIOS
  5. Also in the AppDelegate.m - remove #import <React/RCTPushNotificationManager.h> and replace with #import <RNCPushNotificationIOS.h>
  6. In xCode, clean your build directory (Product -> Clean Build Folder)
  7. Build

This one caught me off guard so I hope this helps someone!

All 10 comments

Hi @Return-1 ...the library work for you in ios and RN 0.59.10???...not for me... I dont know what is the problem... I enabled Push notification in profiles and XCode...but nothing work.. thanks in advance.

Ready sorry..the documentation is so bad....

I was able to get it running by installing the master the latest version of @react-native-community/push-notification-ios (^1.0.2), and the fork of this lib that's used in this pr: https://github.com/zo0r/react-native-push-notification/pull/1139

React-native auto linking did the rest.

I know its a stop-gap solution, but I'm just dropping this here if it might unblock someone

Thanks @GertjanReynaert . Right now I try the solution... everything work find for now..but I have a problem .. the problem for the notifications when the app is hide in iOS, stil happen.

For ios It is uses the PushNotificationIOS. If you have set up your React with podfiles you can just add to your podfile:
pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
and do a pod install in ios.

thanks @thekrol01 I use the PushNotificationIOS community right now so the path path => '../node_modules/react-native/Libraries/PushNotificationIOS' is different... in other way in simulation work fine but not in hide...with local notifications... but I have a big problem when I try to make a release. "iOSPushNotification.a" is not find.

With the latest version of react-native-push-notification (3.1.8) and @react-native-community/push-notifications-ios (1.0.2) I was able to get things working in RN60 by just doing the npm install and using the auto loading of RN60

HI @GertjanReynaert - thanks for sharing. I can also confirm that the latest build works fine react-native-push-notification (3.1.8) and @react-native-community/push-notifications-ios (1.0.2.

The install instructions look like they have been updated, but for anyone coming from a previous release where they were using React-RCTPushNotification here are the steps:

Firstly, React-RCTPushNotification has been removed from the normal react package (just like ASyncStorage was) and now resides within the community. Therefore you will need to:

  1. Remove your PodFile entry for React-RCTPushNotification (your PodFile is in the ios directory): Remove this:
    pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
  2. Install the new push notification module into your project: yarn add @react-native-community/push-notifications-ios
  3. Go back to ios and runpod install
  4. Replace all entries in your AppDelegate.m for RCTPushNotificationManager with RNCPushNotificationIOS
  5. Also in the AppDelegate.m - remove #import <React/RCTPushNotificationManager.h> and replace with #import <RNCPushNotificationIOS.h>
  6. In xCode, clean your build directory (Product -> Clean Build Folder)
  7. Build

This one caught me off guard so I hope this helps someone!

@GertjanReynaert I work with 0.59.10 RN and doesnt work..

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaniShalash picture DaniShalash  路  3Comments

cidevant picture cidevant  路  3Comments

atteia picture atteia  路  4Comments

nidzovito picture nidzovito  路  3Comments

ssolida picture ssolida  路  3Comments