@react-native-firebase/messaging 15.1.1 → 15.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [15.4.0](https://github.com/invertase/react-native-firebase/compare/v15.3.0...v15.4.0) (2022-08-27)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **messaging, ios:** Support Ephemeral authorization state ([#6478](https://github.com/invertase/react-native-firebase/issues/6478)) ([795b684](https://github.com/invertase/react-native-firebase/commit/795b68472deb0089ac4ddf7270e361a2db1da351))
11
+
12
+ # [15.3.0](https://github.com/invertase/react-native-firebase/compare/v15.2.0...v15.3.0) (2022-08-07)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **ios, messaging:** depend directly on FirebaseCoreExtension pod ([62ee54b](https://github.com/invertase/react-native-firebase/commit/62ee54b8a7d273430cbebf88af1d8a96fed6a6a6)), closes [#6403](https://github.com/invertase/react-native-firebase/issues/6403) [#6352](https://github.com/invertase/react-native-firebase/issues/6352)
17
+ - **messaging, ios:** eliminate auth/messaging notification race ([#6455](https://github.com/invertase/react-native-firebase/issues/6455)) ([7183118](https://github.com/invertase/react-native-firebase/commit/71831188a4d90800cce424a5a3cfb29978391bd3))
18
+
19
+ # [15.2.0](https://github.com/invertase/react-native-firebase/compare/v15.1.1...v15.2.0) (2022-07-21)
20
+
21
+ ### Features
22
+
23
+ - **ios, messaging:** Allow notifications in foreground on iOS, configure in firebase.json ([#6407](https://github.com/invertase/react-native-firebase/issues/6407)) ([71dee2b](https://github.com/invertase/react-native-firebase/commit/71dee2bac7a2ea58e51605a249cab7f1ac5fa7d7))
24
+
6
25
  ## [15.1.1](https://github.com/invertase/react-native-firebase/compare/v15.1.0...v15.1.1) (2022-06-28)
7
26
 
8
27
  **Note:** Version bump only for package @react-native-firebase/messaging
@@ -28,6 +28,7 @@ Pod::Spec.new do |s|
28
28
  s.dependency 'React-Core'
29
29
  s.dependency 'RNFBApp'
30
30
 
31
+
31
32
  if defined?($FirebaseSDKVersion)
32
33
  Pod::UI.puts "#{s.name}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
33
34
  firebase_sdk_version = $FirebaseSDKVersion
@@ -35,6 +36,7 @@ Pod::Spec.new do |s|
35
36
 
36
37
  # Firebase dependencies
37
38
  s.dependency 'Firebase/Messaging', firebase_sdk_version
39
+ s.dependency 'FirebaseCoreExtension', firebase_sdk_version
38
40
 
39
41
  if defined?($RNFirebaseAsStaticFramework)
40
42
  Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
@@ -34,7 +34,6 @@ def firebaseBomVersion = appPackageJson['sdkVersions']['android']['firebase']
34
34
  def jsonMinSdk = appPackageJson['sdkVersions']['android']['minSdk']
35
35
  def jsonTargetSdk = appPackageJson['sdkVersions']['android']['targetSdk']
36
36
  def jsonCompileSdk = appPackageJson['sdkVersions']['android']['compileSdk']
37
- def jsonBuildTools = appPackageJson['sdkVersions']['android']['buildTools']
38
37
  def coreVersionDetected = appPackageJson['version']
39
38
  def coreVersionRequired = packageJson['peerDependencies'][appPackageJson['name']]
40
39
  // Only log after build completed so log warning appears at the end
@@ -51,9 +50,6 @@ project.ext {
51
50
  minSdk : jsonMinSdk,
52
51
  targetSdk : jsonTargetSdk,
53
52
  compileSdk: jsonCompileSdk,
54
- // optional as gradle.buildTools comes with one by default
55
- // overriding here though to match the version RN uses
56
- buildTools: jsonBuildTools
57
53
  ],
58
54
 
59
55
  firebase: [
@@ -123,6 +123,24 @@
123
123
  completionHandler(UIBackgroundFetchResultNoData);
124
124
  return;
125
125
  }
126
+
127
+ // If the notification is a probe notification, always call the completion
128
+ // handler with UIBackgroundFetchResultNoData.
129
+ //
130
+ // This fixes a race condition between `FIRAuth/didReceiveRemoteNotification` and this
131
+ // module causing detox to hang when `FIRAuth/didReceiveRemoteNotification` is called first.
132
+ // see
133
+ // https://stackoverflow.com/questions/72044950/detox-tests-hang-with-pending-items-on-dispatch-queue/72989494
134
+ NSDictionary *data = userInfo[@"com.google.firebase.auth"];
135
+ if ([data isKindOfClass:[NSString class]]) {
136
+ // Deserialize in case the data is a JSON string.
137
+ NSData *JSONData = [((NSString *)data) dataUsingEncoding:NSUTF8StringEncoding];
138
+ data = [NSJSONSerialization JSONObjectWithData:JSONData options:0 error:NULL];
139
+ }
140
+ if ([data isKindOfClass:[NSDictionary class]] && data[@"warning"]) {
141
+ completionHandler(UIBackgroundFetchResultNoData);
142
+ return;
143
+ }
126
144
  #endif
127
145
 
128
146
  [[NSNotificationCenter defaultCenter]
@@ -17,6 +17,7 @@
17
17
 
18
18
  #import <RNFBApp/RNFBRCTEventEmitter.h>
19
19
 
20
+ #import "RNFBJSON.h"
20
21
  #import "RNFBMessaging+UNUserNotificationCenter.h"
21
22
  #import "RNFBMessagingSerializer.h"
22
23
 
@@ -82,6 +83,50 @@ struct {
82
83
  willPresentNotification:(UNNotification *)notification
83
84
  withCompletionHandler:
84
85
  (void (^)(UNNotificationPresentationOptions options))completionHandler {
86
+ NSArray *presentationOptionsConfig =
87
+ [[RNFBJSON shared] getArrayValue:@"messaging_ios_foreground_presentation_options"
88
+ defaultValue:@[]];
89
+
90
+ UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionNone;
91
+
92
+ BOOL badge = [presentationOptionsConfig containsObject:@"badge"];
93
+ BOOL sound = [presentationOptionsConfig containsObject:@"sound"];
94
+ BOOL alert = [presentationOptionsConfig containsObject:@"alert"];
95
+ BOOL list = [presentationOptionsConfig containsObject:@"list"];
96
+ BOOL banner = [presentationOptionsConfig containsObject:@"banner"];
97
+
98
+ if (badge) {
99
+ presentationOptions |= UNNotificationPresentationOptionBadge;
100
+ }
101
+
102
+ if (sound) {
103
+ presentationOptions |= UNNotificationPresentationOptionSound;
104
+ }
105
+
106
+ // if list or banner is true, ignore `alert` property
107
+ if (banner || list) {
108
+ if (banner) {
109
+ if (@available(iOS 14, *)) {
110
+ presentationOptions |= UNNotificationPresentationOptionBanner;
111
+ } else {
112
+ // for iOS 13 we need to set `alert`
113
+ presentationOptions |= UNNotificationPresentationOptionAlert;
114
+ }
115
+ }
116
+
117
+ if (list) {
118
+ if (@available(iOS 14, *)) {
119
+ presentationOptions |= UNNotificationPresentationOptionList;
120
+ } else {
121
+ // for iOS 13 we need to set `alert`
122
+ presentationOptions |= UNNotificationPresentationOptionAlert;
123
+ }
124
+ }
125
+ } else if (alert) {
126
+ // TODO: Remove `alert` once iOS 14 becomes the minimum deployment target
127
+ presentationOptions |= UNNotificationPresentationOptionAlert;
128
+ }
129
+
85
130
  if (notification.request.content.userInfo[@"gcm.message_id"]) {
86
131
  NSDictionary *notificationDict = [RNFBMessagingSerializer notificationToDict:notification];
87
132
 
@@ -91,9 +136,7 @@ struct {
91
136
  [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_message_received"
92
137
  body:notificationDict];
93
138
  }
94
-
95
- // TODO in a later version allow customising completion options in JS code
96
- completionHandler(UNNotificationPresentationOptionNone);
139
+ completionHandler(presentationOptions);
97
140
  }
98
141
 
99
142
  if (_originalDelegate != nil && originalDelegateRespondsTo.willPresentNotification) {
@@ -101,7 +144,7 @@ struct {
101
144
  willPresentNotification:notification
102
145
  withCompletionHandler:completionHandler];
103
146
  } else {
104
- completionHandler(UNNotificationPresentationOptionNone);
147
+ completionHandler(presentationOptions);
105
148
  }
106
149
  }
107
150
 
@@ -321,6 +321,12 @@ RCT_EXPORT_METHOD(hasPermission : (RCTPromiseResolveBlock)resolve : (RCTPromiseR
321
321
  }
322
322
  }
323
323
 
324
+ if (@available(iOS 14.0, macCatalyst 14.0, *)) {
325
+ if (settings.authorizationStatus == UNAuthorizationStatusEphemeral) {
326
+ authorizedStatus = @3;
327
+ }
328
+ }
329
+
324
330
  resolve(authorizedStatus);
325
331
  }];
326
332
  } else {
package/lib/index.d.ts CHANGED
@@ -501,6 +501,13 @@ export namespace FirebaseMessagingTypes {
501
501
  * @platform ios iOS >= 12
502
502
  */
503
503
  PROVISIONAL = 2,
504
+
505
+ /**
506
+ * The app is authorized to create notifications for a limited amount of time.
507
+ * Used in App Clips.
508
+ * @platform ios iOS >= 14
509
+ */
510
+ EPHEMERAL = 3,
504
511
  }
505
512
 
506
513
  /**
package/lib/index.js CHANGED
@@ -40,6 +40,7 @@ const statics = {
40
40
  DENIED: 0,
41
41
  AUTHORIZED: 1,
42
42
  PROVISIONAL: 2,
43
+ EPHEMERAL: 3,
43
44
  },
44
45
  NotificationAndroidPriority: {
45
46
  PRIORITY_MIN: -2,
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '15.1.1';
2
+ module.exports = '15.4.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/messaging",
3
- "version": "15.1.1",
3
+ "version": "15.4.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - React Native Firebase provides native integration of Firebase Cloud Messaging (FCM) for both Android & iOS. FCM is a cost free service, allowing for server-device and device-device communication. The React Native Firebase Messaging module provides a simple JavaScript API to interact with FCM.",
6
6
  "main": "lib/index.js",
@@ -22,10 +22,10 @@
22
22
  "messaging"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@react-native-firebase/app": "15.1.1"
25
+ "@react-native-firebase/app": "15.4.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "8d469f19b9faec54c492f83c0a2dba6a52815da3"
30
+ "gitHead": "a05f63d5cb208d9b6f645a0743584f58a942d6bc"
31
31
  }