Closed nolife08021 closed 4 years ago
Sorry - I appreciate that you provided the info but I'm afraid it shows you are on react-native-firebase v5 - that is long out of support now, you need to perform the migration to current stable versions of react-native-firebase and try to reproduce again - https://rnfirebase.io/migrating-to-v6
Issue
After unsubscribe all the topics but still receiving notifications. firebase.iid().delete() unsubscription works, but not able to subscribe again.
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "my_react", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "postinstall": "npx jetify", "lint": "eslint ." }, "dependencies": { "@react-native-community/async-storage": "^1.6.2", "@react-native-community/audio-toolkit": "^2.0.3", "@react-native-community/blur": "^3.4.1", "@react-native-community/netinfo": "^4.3.2", "@react-native-community/push-notification-ios": "^1.0.2", "buffer": "^5.4.3", "deprecated-react-native-listview": "0.0.5", "install": "^0.13.0", "jsc-android": "^241213.1.0", "lottie-ios": "^3.1.3", "lottie-react-native": "^3.3.2", "moment": "^2.24.0", "moment-timezone": "^0.5.26", "react": "^16.9.0", "react-dom": "^16.10.2", "react-moment": "^0.9.2", "react-native": "0.61.2", "react-native-admob": "^2.0.0-beta.6", "react-native-animatable": "^1.3.2", "react-native-app-intro-slider": "^3.0.0", "react-native-badger-android": "^1.0.4", "react-native-calendar-picker": "^6.0.5", "react-native-calendars": "^1.263.0", "react-native-camera": "^3.6.0", "react-native-collapse-view": "^1.0.0", "react-native-country-picker-modal": "^1.1.0", "react-native-custom-checkbox": "^1.5.2", "react-native-datepicker": "^1.7.2", "react-native-device-info": "^3.1.4", "react-native-exit-app": "^1.1.0", "react-native-firebase": "^5.5.6", "react-native-form-validator": "^0.2.0", "react-native-gifted-chat": "^0.13.0", "react-native-image-crop-picker": "^0.25.3", "react-native-image-pan-zoom": "^2.1.11", "react-native-image-resizer": "^1.0.1", "react-native-image-zoom-viewer": "^2.2.26", "react-native-keyboard-aware-scroll-view": "^0.9.1", "react-native-loading-spinner-overlay": "^1.0.1", "react-native-material-bottom-navigation": "^1.0.4", "react-native-material-buttons": "^0.6.0", "react-native-md5": "^1.0.0", "react-native-modal": "^11.4.0", "react-native-numeric-input": "^1.8.3", "react-native-offline": "^5.1.0", "react-native-paper": "^2.16.0", "react-native-permissions": "^2.0.8", "react-native-pure-chart": "0.0.24", "react-native-push-notification": "^3.1.9", "react-native-qrcode-scanner": "^1.3.1", "react-native-render-html": "^4.1.2", "react-native-responsive-screen": "^1.3.0", "react-native-restart": "0.0.13", "react-native-scalable-image": "^1.0.0", "react-native-secure-key-store": "^2.0.5", "react-native-share": "^3.1.2", "react-native-simple-radio-button": "^2.7.3", "react-native-sound": "^0.11.0", "react-native-sound-playerview": "^1.0.0", "react-native-sqlite-storage": "^4.1.0", "react-native-super-grid": "^3.1.1", "react-native-svg": "^9.11.1", "react-native-swipeout": "^2.3.6", "react-native-switch": "^1.5.0", "react-native-validation": "^1.0.2", "react-native-vector-icons": "^6.6.0", "react-native-web": "^0.11.7", "react-native-webview": "^7.4.1", "react-navigation": "^2.3.0", "rn-fetch-blob": "^0.11.2", "victory-native": "^33.0.0" }, "devDependencies": { "@babel/core": "7.6.2", "@babel/runtime": "7.6.2", "jetifier": "^1.6.4", "@react-native-community/eslint-config": "0.0.3", "babel-jest": "24.9.0", "eslint": "6.5.1", "jest": "24.9.0", "metro-react-native-babel-preset": "0.51.1", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' target 'my_react' do # Pods for my_react pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga' pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' pod 'Google-Mobile-Ads-SDK' pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios' pod 'Firebase/Core', '~> 6.3.0' pod 'Firebase/Messaging', '~> 6.3.0' pod 'Fabric', '~> 1.10.2' pod 'Crashlytics', '~> 3.13.2' pod 'react-native-admob', path: '../node_modules/react-native-admob' pod 'GoogleAppMeasurement' pod 'react-native-sqlite-storage', :path => '../node_modules/react-native-sqlite-storage' permissions_path = '../node_modules/react-native-permissions/ios' # pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec" pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec" pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec" pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec" pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec" pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec" pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec" pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec" pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec" pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec" pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec" pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec" pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec" pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec" pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec" pod 'react-native-blur', :path => '../node_modules/@react-native-community/blur' target 'my_reactTests' do inherit! :search_paths # Pods for testing end use_native_modules! end target 'my_react-tvOS' do # Pods for my_react-tvOS target 'my_react-tvOSTests' do inherit! :search_paths # Pods for testing end end ``` #### `AppDelegate.m`: ```objc /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "AppDelegate.h" #import
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#import
#import
@import GoogleMobileAds;
#import
#import
#import
@implementation AppDelegate
NSString *const kGCMMessageIDKey = @"gcm.message_id";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initialize Google Mobile Ads SDK
// Sample AdMob app ID: ca-app-pub-3940256099942544~1458002511
[GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"];
// [START configure_firebase]
[FIRApp configure];
// [END configure_firebase]
[RNFirebaseNotifications configure];
// added
[FIRMessaging messaging].shouldEstablishDirectChannel = YES;
// Register for remote notifications. This shows a permission dialog on first run, to
// show the dialog at a more appropriate time move this registration accordingly.
// [START register_for_notifications]
if ([UNUserNotificationCenter class] != nil) {
// iOS 10 or later
// For iOS 10 display notification (sent via APNS)
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[FIRMessaging messaging].delegate = self;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {if (error) { NSLog(@"%@", error); }
}];
} else {
// iOS 10 notifications aren't available; fall back to iOS 8-9 notifications.
UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
}
[application registerForRemoteNotifications];
// [END register_for_notifications]
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"my_react"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; //Add This Line
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *oldAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *newAgent = [oldAgent stringByAppendingString:@"myios"];
NSDictionary *dictionnary = [[NSDictionary alloc] initWithObjectsAndKeys:newAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionnary];
return YES;
}
// react native firebase methods from documentation
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"info %@", userInfo); // added
[[FIRMessaging messaging] appDidReceiveMessage:userInfo]; // added
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"Remote notification device token: %@", deviceToken);
}
- (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"PUSH ERROR: %@", error);
}
// *************************** not sure if these are needed ***********************************
// [START receive_message]
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[FIRMessaging messaging] appDidReceiveMessage:userInfo];
[[RNFirebaseMessaging instance] didReceiveRemoteNotification:userInfo];
}
//// [END receive_message]
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RCTLinkingManager application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
//- (void)applicationDidBecomeActive:(UIApplication *)application{
// [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
//}
//
//-(void)applicationDidEnterBackground:(UIApplication *)application{
// [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
//}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
```
Android
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```
Environment
Click To Expand
**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - v5.5.6 - **`Firebase` module(s) you're using that has the issue:** - Messaging - **Are you using `TypeScript`?** - No
React Native Firebase
andInvertase
on Twitter for updates on the library.