Skip to content

Commit 9eb9967

Browse files
fix(firebase_messaging): check userInfo for "aps.notification" property presence for firing data only messages. (#8759)
1 parent a11bd60 commit 9eb9967

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CLIENT_ID</key>
6+
<string>448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu.apps.googleusercontent.com</string>
7+
<key>REVERSED_CLIENT_ID</key>
8+
<string>com.googleusercontent.apps.448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu</string>
9+
<key>ANDROID_CLIENT_ID</key>
10+
<string>448618578101-29lqo5a1alrq4uplsf9bl92jb84j1ee6.apps.googleusercontent.com</string>
11+
<key>API_KEY</key>
12+
<string>AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0</string>
13+
<key>GCM_SENDER_ID</key>
14+
<string>448618578101</string>
15+
<key>PLIST_VERSION</key>
16+
<string>1</string>
17+
<key>BUNDLE_ID</key>
18+
<string>io.flutter.plugins.firebase.messaging</string>
19+
<key>PROJECT_ID</key>
20+
<string>react-native-firebase-testing</string>
21+
<key>STORAGE_BUCKET</key>
22+
<string>react-native-firebase-testing.appspot.com</string>
23+
<key>IS_ADS_ENABLED</key>
24+
<false></false>
25+
<key>IS_ANALYTICS_ENABLED</key>
26+
<false></false>
27+
<key>IS_APPINVITE_ENABLED</key>
28+
<true></true>
29+
<key>IS_GCM_ENABLED</key>
30+
<true></true>
31+
<key>IS_SIGNIN_ENABLED</key>
32+
<true></true>
33+
<key>GOOGLE_APP_ID</key>
34+
<string>1:448618578101:ios:0b11ed8263232715ac3efc</string>
35+
<key>DATABASE_URL</key>
36+
<string>https://react-native-firebase-testing.firebaseio.com</string>
37+
</dict>
38+
</plist>

packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/project.pbxproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 51;
6+
objectVersion = 50;
77
objects = {
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12+
465BDD1E283BB5B000437DF4 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */; };
1213
88A1BA888F20E378BC794541 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61672002202DF3E143D4F450 /* libPods-Runner.a */; };
1314
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1415
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -35,6 +36,7 @@
3536
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3637
27715A442538A1AE00757C2A /* Firebase Cloud Messaging Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Firebase Cloud Messaging Example.entitlements"; sourceTree = "<group>"; };
3738
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
39+
465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
3840
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>"; };
3941
61672002202DF3E143D4F450 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4042
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -88,6 +90,7 @@
8890
97C146E51CF9000F007C117D = {
8991
isa = PBXGroup;
9092
children = (
93+
465BDD1D283BB5B000437DF4 /* GoogleService-Info.plist */,
9194
9740EEB11CF90186004384FC /* Flutter */,
9295
97C146F01CF9000F007C117D /* Runner */,
9396
97C146EF1CF9000F007C117D /* Products */,
@@ -167,7 +170,7 @@
167170
97C146E61CF9000F007C117D /* Project object */ = {
168171
isa = PBXProject;
169172
attributes = {
170-
LastUpgradeCheck = 1020;
173+
LastUpgradeCheck = 1300;
171174
ORGANIZATIONNAME = "";
172175
TargetAttributes = {
173176
97C146ED1CF9000F007C117D = {
@@ -200,6 +203,7 @@
200203
files = (
201204
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
202205
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
206+
465BDD1E283BB5B000437DF4 /* GoogleService-Info.plist in Resources */,
203207
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
204208
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
205209
);

packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1020"
3+
LastUpgradeVersion = "1300"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

packages/firebase_messaging/firebase_messaging/example/lib/main.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
3737

3838
Future<void> main() async {
3939
WidgetsFlutterBinding.ensureInitialized();
40-
await Firebase.initializeApp(
41-
options: DefaultFirebaseOptions.currentPlatform,
42-
);
40+
await Firebase.initializeApp();
4341

4442
// Set the background messaging handler early on, as a named top-level function
4543
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ - (void)application:(NSApplication *)application
422422
#endif
423423

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

0 commit comments

Comments
 (0)