Skip to content

Commit

Permalink
fix(firebase_messaging): check userInfo for "aps.notification" prop…
Browse files Browse the repository at this point in the history
…erty presence for firing data only messages. (#8759)
  • Loading branch information
russellwheatley committed May 26, 2022
1 parent a11bd60 commit 9eb9967
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu</string>
<key>ANDROID_CLIENT_ID</key>
<string>448618578101-29lqo5a1alrq4uplsf9bl92jb84j1ee6.apps.googleusercontent.com</string>
<key>API_KEY</key>
<string>AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0</string>
<key>GCM_SENDER_ID</key>
<string>448618578101</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.flutter.plugins.firebase.messaging</string>
<key>PROJECT_ID</key>
<string>react-native-firebase-testing</string>
<key>STORAGE_BUCKET</key>
<string>react-native-firebase-testing.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:448618578101:ios:0b11ed8263232715ac3efc</string>
<key>DATABASE_URL</key>
<string>https://react-native-firebase-testing.firebaseio.com</string>
</dict>
</plist>
Expand Up @@ -3,12 +3,13 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
465BDD1E283BB5B000437DF4 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */; };
88A1BA888F20E378BC794541 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61672002202DF3E143D4F450 /* libPods-Runner.a */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand All @@ -35,6 +36,7 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
27715A442538A1AE00757C2A /* Firebase Cloud Messaging Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Firebase Cloud Messaging Example.entitlements"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
5213D4DB21693B7FDB92C6A0 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
61672002202DF3E143D4F450 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -88,6 +90,7 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
Expand Down Expand Up @@ -167,7 +170,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -200,6 +203,7 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
465BDD1E283BB5B000437DF4 /* GoogleService-Info.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Expand Up @@ -37,9 +37,7 @@ late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
await Firebase.initializeApp();

// Set the background messaging handler early on, as a named top-level function
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
Expand Down
Expand Up @@ -422,7 +422,7 @@ - (void)application:(NSApplication *)application
#endif

#if !TARGET_OS_OSX
// Called for silent notifications in the foreground & background
// Called for silent messages (i.e. data only) in the foreground & background
- (BOOL)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
Expand Down Expand Up @@ -484,9 +484,9 @@ - (BOOL)application:(UIApplication *)application
}
}];
} else {
// If "alert" (i.e. notification) is present, this will be called by the other
// If "alert" (i.e. notification) is present in userInfo, this will be called by the other
// "Messaging#onMessage" channel handler
if (notificationDict[@"aps"] != nil && notificationDict[@"aps"][@"alert"] == nil) {
if (userInfo[@"aps"] != nil && userInfo[@"aps"][@"alert"] == nil) {
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
}
completionHandler(UIBackgroundFetchResultNoData);
Expand Down

0 comments on commit 9eb9967

Please sign in to comment.