Development Operating System:
Xcode Version : 9.2
Environment:
iOS
Application Target Platform:
macOS Sierra
"react-native": "^0.54.3",
"react-native-firebase": "^4.0.0-rc.2",
Issue:
its happening when I migrated from 3.3.1 to 4.0.0-rc.2, however, I made all changes carefully into appdelegate.m , appdelegate.h
PodLock file
````
PODS:
DEPENDENCIES:
SPEC CHECKSUMS:
BoringSSL: ************** ( I hide intentionally )
Firebase: ************** ( I hide intentionally )
FirebaseAnalytics: ************** ( I hide intentionally )
FirebaseAuth: ************** ( I hide intentionally )
FirebaseCore: ************** ( I hide intentionally )
FirebaseDatabase: ************** ( I hide intentionally )
FirebaseFirestore: ************** ( I hide intentionally )
FirebaseInstanceID: ************** ( I hide intentionally )
FirebaseMessaging: ************** ( I hide intentionally )
FirebaseStorage: ************** ( I hide intentionally )
GoogleToolboxForMac: ************** ( I hide intentionally )
gRPC: ************** ( I hide intentionally )
gRPC-Core: ************** ( I hide intentionally )
gRPC-ProtoRPC: ************** ( I hide intentionally )
gRPC-RxLibrary: ************** ( I hide intentionally )
GTMSessionFetcher: ************** ( I hide intentionally )
leveldb-library: ************** ( I hide intentionally )
nanopb: ************** ( I hide intentionally )
Protobuf: ************** ( I hide intentionally )
QBImagePickerController: ************** ( I hide intentionally )
RSKImageCropper: *************** ( I hide intentionally )
PODFILE CHECKSUM: *************** ( I hide intentionally )
COCOAPODS: 1.4.0
````
JS code
````
firebase.messaging().requestPermissions()
.then(() => {
// User has authorised
console.log('the notification')
})
.catch(error => {
// User has rejected permissions
});
...
...
firebase.messaging().subscribeToTopic('all')
.then(function(response) { console.log('Successfully subscribed to topic:', response);
}) .catch(function(error) {
console.log('Error subscribing to topic:', error);
});
````
Appdelegate.h
````
@interface AppDelegate : UIResponder
@property (nonatomic, strong) UIWindow *window;
@end
````
Appdelegate.m
````
@implementation AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[RNFirebaseNotifications configure];
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"myapp"
initialProperties:nil
launchOptions:launchOptions];
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];
return YES;
}
(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
@end
````
Podfile
````
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'
target 'myapp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for myapp
pod 'RSKImageCropper'
pod 'QBImagePickerController'
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Messaging'
pod 'Firebase/Storage'
pod 'Firebase/Firestore'
pod 'Firebase/Auth'
target 'myappTests' do
inherit! :search_paths
# Pods for testing
end
end
````
@amitbravo In response to each of your issues:
1) requestPermissions()
is now requestPermission()
to match the web SDK.
2) subscribeToTopic()
is currently not a Promise, but will be changed for the next release candidate so that it is
can I still use subscribeToTopic() without .then(.... ?
You can indeed
I'm facing the exact same issue with the syntax given in the docs.
Here is the description -
Package.json -
"react-native-firebase": "4.0.0-rc.3",
Usage -
componentDidMount(): void {
this.connectToFirebase();
}
connectToFirebase = (): void => {
// I've tried using this with async-await, tried
// resolving the promise using .then. I also tried calling hasPermission. Same issue.
firebase.messaging().requestPermission();
registerNotificationListener(this.onNotification);
registerMessageListener(this.onMessage);
}
Error -
When calling requestPermission
directly (Without resolving the promise) -
When requestPermission
is called using async-await
-
When hasPermission
is called -
Is there something I might have missed? Help needed.
I have run into the same issue as @omkarjoshi-cc regarding hasPermission
@danielmilner @omkarjoshi-cc Using old version?
https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0
@setkyar Yeah, I haven't upgraded to v4 yet. I'll try using v4 and report if the issue still persists.
Most helpful comment
@amitbravo In response to each of your issues:
1)
requestPermissions()
is nowrequestPermission()
to match the web SDK.2)
subscribeToTopic()
is currently not a Promise, but will be changed for the next release candidate so that it is