diff --git a/Examples/simple-fcm-client/app/Listeners.js b/Examples/simple-fcm-client/app/Listeners.js index 0144e1f55ee357d441663b83e0c47f69ecf3300c..25e581fed2b45706dcc144d64e58fb01d408b3cd 100644 --- a/Examples/simple-fcm-client/app/Listeners.js +++ b/Examples/simple-fcm-client/app/Listeners.js @@ -42,6 +42,8 @@ export function registerAppListener(){ break; case NotificationType.WillPresent: notif.finish(WillPresentNotificationResult.All) //other types available: WillPresentNotificationResult.None + // this type of notificaiton will be called only when you are in foreground. + // if it is a remote notification, don't do any app logic here. Another notification callback will be triggered with type NotificationType.Remote break; } } diff --git a/README.md b/README.md index e29c07bf0855b3f7fd6cddae5b34be03a2490d9d..e7b4c07d868752872e1e7cc63566fe56a55c2c96 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-clien ... android:theme="@style/AppTheme"> ++ + + + + @@ -187,7 +189,7 @@ cd ios && pod init Edit the newly created `Podfile`: ```diff # Pods for YOURAPP -+ pod 'FirebaseMessaging' ++ pod 'Firebase/Messaging' ``` Install the `Firebase/Messaging` pod: @@ -277,7 +279,6 @@ Edit AndroidManifest.xml + + + + diff --git a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java index 19f16f51068ff5b88d6b96dcf60b7aacfc3fd83a..a71173351f9065654d69f93c939af943176a7d02 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java @@ -58,7 +58,10 @@ public class FIRLocalMessagingHelper { return; } - Long fireDate = Math.round(bundle.getDouble("fire_date", bundle.getLong("fire_date"))); + long fireDate = Math.round(bundle.getDouble("fire_date")); + if(fireDate == 0){ + fireDate = Math.round(bundle.getLong("fire_date")); + } if (fireDate == 0) { Log.e(TAG, "failed to schedule notification because fire date is missing"); return; diff --git a/ios/RNFIRMessaging.m b/ios/RNFIRMessaging.m index 271dac8a5bbe7dc8729ef98b90f614968fe658e6..8bc4ae34026a7afd0df3f4c71a6607d5b855c005 100644 --- a/ios/RNFIRMessaging.m +++ b/ios/RNFIRMessaging.m @@ -367,7 +367,9 @@ RCT_EXPORT_METHOD(removeAllDeliveredNotifications) if([UNUserNotificationCenter currentNotificationCenter] != nil){ [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications]; } else { - [RCTSharedApplication() setApplicationIconBadgeNumber: 0]; + dispatch_async(dispatch_get_main_queue(), ^{ + [RCTSharedApplication() setApplicationIconBadgeNumber: 0]; + }); } } @@ -416,7 +418,9 @@ RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve RCT_EXPORT_METHOD(setBadgeNumber: (NSInteger) number) { - [RCTSharedApplication() setApplicationIconBadgeNumber:number]; + dispatch_async(dispatch_get_main_queue(), ^{ + [RCTSharedApplication() setApplicationIconBadgeNumber:number]; + }); } RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) diff --git a/ios/RNFIRMessaging.xcodeproj/project.pbxproj b/ios/RNFIRMessaging.xcodeproj/project.pbxproj index f662aef6d3e04e7e8d0eb4cc1b1d7819a90c8d0c..855a0128228cac8dff27daf8ac2fe92ff7733ed2 100644 --- a/ios/RNFIRMessaging.xcodeproj/project.pbxproj +++ b/ios/RNFIRMessaging.xcodeproj/project.pbxproj @@ -230,6 +230,7 @@ "$(PROJECT_DIR)/../../../ios/Frameworks/**", "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**", "$(PROJECT_DIR)/../../../ios/Pods/Firebase/**", + "$(PROJECT_DIR)/../../../ios/Pods/Headers/Public/**", ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; @@ -257,6 +258,7 @@ "$(PROJECT_DIR)/../../../ios/Frameworks/**", "$(SRCROOT)/../../../node_modules/react-native-firestack/ios/**", "$(PROJECT_DIR)/../../../ios/Pods/Firebase/**", + "$(PROJECT_DIR)/../../../ios/Pods/Headers/Public/**", ); LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; diff --git a/package.json b/package.json index 1100ac0684ca3ff052dc090bc876ebfac0119bf4..d60c503c57bd1ff8526a0ff75cfcb8a2e33ce398 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,5 @@ "type": "git", "url": "git+https://github.com/evollu/react-native-fcm.git" }, - "version": "11.2.0" + "version": "11.3.1" } diff --git a/react-native-fcm.podspec b/react-native-fcm.podspec index 619f2fa64217008385b602c75b4c82643a16d16c..0eb8862a9be8189b3a758794e13494fa7be848fb 100644 --- a/react-native-fcm.podspec +++ b/react-native-fcm.podspec @@ -12,6 +12,9 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/evollu/react-native-fcm.git' } s.platform = :ios, '8.0' s.source_files = "ios/*.{h,m}" + s.public_header_files = ['ios/RNFIRMessaging.h'] + s.static_framework = true + s.dependency "React" s.dependency "Firebase/Messaging" end