1
votes

I integrated react-native-push-notification with ios and android following the documentation, also some tutorials on youtube, but I have a problem, I'm not receiving any notification, even local notification, on the iOS device, but on Android, it's working well. I don't know if I need to show you the code, because is the same as in the documentation.

By the way, I'm using firebase for cloud messaging and I configured it with my p8 key.

3
please share the code which send notification - Dima Portenko

3 Answers

1
votes

I had the similar issue even though every related settings were turned on. Was frustrating - i used "hi security " from Google Play store which manages the notifications. After "notification" was set to ON, I found all of the badges are showing up - missed call and unread messages on both home screen and app.

0
votes

I also tried with react-native-firebase but it does not work.No push notification is received . Later I Implemented push notification using react-native-fcm and it worked. You can check the link https://github.com/evollu/react-native-fcm

0
votes

You are not receiving notification probably because firebase is not integrated properly in your application. The steps to integrate properly are given below:

react-native-firebase library did not work for me .Integrating firebase to react native application using react-native-fcm succeded in receiving push notifications.

1.Install react-native-fcm: npm install react-native-fcm --save

  1. From firebase console, for Android: download google-services.json file and place it in android/app directory. for iOS: download GoogleService-Info.plist file and place it in /ios/your-project-name directory (next to your Info.plist)

3.Configure the project using : cd ios && pod init

4.Edit the newly created Podfile: pod install

5.Edit AppDelegate.h:

    @import UserNotifications;

    @interface AppDelegate:UIResponder<UIApplicationDelegate,UNUserNotificationCenterDelegate>

    @interface AppDelegate : UIResponder <UIApplicationDelegate>

6.Edit AppDelegate.m:

#import "RNFIRMessaging.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

[FIRApp configure];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

return YES;

}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center 
willPresentNotification:(UNNotification *)notification 
withCompletionHandler:(void (^) . 
      (UNNotificationPresentationOptions))completionHandler
 {
    [RNFIRMessaging willPresentNotification:notification 
     withCompletionHandler:completionHandler];
 }

#if defined(__IPHONE_11_0)

- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
  didReceiveNotificationResponse:(UNNotificationResponse *)response 
   withCompletionHandler:(void (^)(void))completionHandler
{
    [RNFIRMessaging didReceiveNotificationResponse:response 
     withCompletionHandler:completionHandler];
}

#else

- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
  didReceiveNotificationResponse:(UNNotificationResponse *)response 
  withCompletionHandler:(void(^)())completionHandler
{
    [RNFIRMessaging didReceiveNotificationResponse:response 
    withCompletionHandler:completionHandler];
 }

#endif

 //You can skip this method if you don't want to use local notification
-(void)application:(UIApplication *)application 
didReceiveLocalNotification:(UILocalNotification *)notification {

[RNFIRMessaging didReceiveLocalNotification:notification];

 }

- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo 
fetchCompletionHandler:(nonnull void (^) . 
(UIBackgroundFetchResult))completionHandler{

[RNFIRMessaging didReceiveRemoteNotification:userInfo 
fetchCompletionHandler:completionHandler];
}

7.Add the path of header files into XCode:

Open XCode. Press CMD+1 or click the XCode project. Go to Build Settings, selecting All and Combined. Search Header Search Path in the searchg tab. Make sure there is a line of $(SRCROOT)/../node_modules/react-native-fcm/ios. If no, just add it.

8.Add GoogleService-Info.plist:

Make sure the file is not just moved into the folder. You need to Right Click the project folder in XCode and Add File to . Select Copy if needed in the Options page while selecting the file.

9.Shared Library Settings:

Make sure you see Pods.xcodeproj under Library folder if you are using Pod install method. Make sure you see RNFIRMessaging.xcodeproj under Library folder. If you don't see any of these files, please add them by Right Click the Library folder and Add File to to add them back. Pods.xcodeproj should be under ios/Pods/, and RNFIRMessaging.xcodeproj should be under node_modules/react-native-fcm/ios. Make sure you see libRNFIRMessaging.a under Link Binary With Libraries under Build Phases tab. If no, drag the file under RNFIRMessaging.xcodeproj under Library folder into there.

10.Add Capabilities Select your project Capabilities and enable: Push Notifications Background Modes > Remote notifications.

FirebaseAppDelegateProxyEnabled This instruction assumes that you have FirebaseAppDelegateProxyEnabled=YES (default) so that Firebase will hook on push notification registration events. If you turn this flag off, you will be on your own to manage APNS tokens and link with Firebase token.