Skip to content

Commit

Permalink
Merge pull request #1031 from felipeclopes/data-messages-fix
Browse files Browse the repository at this point in the history
Fix handling of data-message once grantPermission is done
  • Loading branch information
robertarnesson authored Jan 27, 2024
2 parents 542c6cd + 525ff02 commit ad0f62e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,20 @@ - (void)grantPermission:(CDVInvokedUrlCommand *)command {


#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert|UNAuthorizationOptionSound|UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {

if (![NSThread isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^{
[[FIRMessaging messaging] setDelegate:self];
[[UIApplication sharedApplication] registerForRemoteNotifications];

CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus: granted ? CDVCommandStatus_OK : CDVCommandStatus_ERROR];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});
} else {
[[FIRMessaging messaging] setDelegate:self];
[[UIApplication sharedApplication] registerForRemoteNotifications];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand Down
2 changes: 1 addition & 1 deletion test/platform-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ PLATFORM_VERSION=$3
FOLDER=".build-$PLATFORM"
cd $FOLDER

../node_modules/.bin/cordova build $PLATFORM
../node_modules/.bin/cordova build $PLATFORM --stacktrace --info

0 comments on commit ad0f62e

Please sign in to comment.