@react-native-firebase/messaging 19.2.2 → 20.0.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,17 @@
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
+ ## [20.0.0](https://github.com/invertase/react-native-firebase/compare/v19.3.0...v20.0.0) (2024-05-20)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/messaging
9
+
10
+ ## [19.3.0](https://github.com/invertase/react-native-firebase/compare/v19.2.2...v19.3.0) (2024-05-20)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **messaging, ios:** register for notifications on permission grant ([ccd78b9](https://github.com/invertase/react-native-firebase/commit/ccd78b9cf5d6961f5252e582ede785932599d25d)), closes [#7272](https://github.com/invertase/react-native-firebase/issues/7272)
15
+ - **messaging, ios:** reject notification registration after 10 seconds ([1f86483](https://github.com/invertase/react-native-firebase/commit/1f8648329ce812644f4bbd0f0caadcfe6a0bbddf)), closes [#7272](https://github.com/invertase/react-native-firebase/issues/7272)
16
+
6
17
  ## [19.2.2](https://github.com/invertase/react-native-firebase/compare/v19.2.1...v19.2.2) (2024-04-13)
7
18
 
8
19
  **Note:** Version bump only for package @react-native-firebase/messaging
@@ -11,7 +11,7 @@ buildscript {
11
11
  }
12
12
 
13
13
  dependencies {
14
- classpath("com.android.tools.build:gradle:8.1.2")
14
+ classpath("com.android.tools.build:gradle:8.4.0")
15
15
  }
16
16
  }
17
17
  }
@@ -284,6 +284,15 @@ RCT_EXPORT_METHOD(requestPermission
284
284
  if (error) {
285
285
  [RNFBSharedUtils rejectPromiseWithNSError:reject error:error];
286
286
  } else {
287
+ // if we do not attempt to register immediately, registration fails
288
+ // later unknown reason why, but this was the only difference between
289
+ // using a react-native-permissions vs built-in permissions request in
290
+ // a sequence of "request permissions" --> "register for messages" you
291
+ // only want to request permission if you want to register for
292
+ // messages, so we register directly now - see #7272
293
+ dispatch_async(dispatch_get_main_queue(), ^{
294
+ [[UIApplication sharedApplication] registerForRemoteNotifications];
295
+ });
287
296
  [self hasPermission:resolve:reject];
288
297
  }
289
298
  }];
@@ -303,8 +312,7 @@ RCT_EXPORT_METHOD(registerForRemoteNotifications
303
312
  : (RCTPromiseRejectBlock)reject) {
304
313
  #if TARGET_IPHONE_SIMULATOR
305
314
  #if !TARGET_CPU_ARM64
306
- // Do the registration on this unsupported simulator, but don't set up to wait for a token that
307
- // won't arrive
315
+ // Register on this unsupported simulator, but no waiting for a token that won't arrive
308
316
  [[UIApplication sharedApplication] registerForRemoteNotifications];
309
317
  resolve(@([RCTConvert BOOL:@(YES)]));
310
318
  return;
@@ -317,6 +325,7 @@ RCT_EXPORT_METHOD(registerForRemoteNotifications
317
325
  if (@available(iOS 10.0, *)) {
318
326
  #pragma pop
319
327
  if ([UIApplication sharedApplication].isRegisteredForRemoteNotifications == YES) {
328
+ DLog(@"RNFBMessaging registerForRemoteNotifications - already registered.");
320
329
  resolve(@([RCTConvert BOOL:@(YES)]));
321
330
  return;
322
331
  } else {
@@ -326,6 +335,32 @@ RCT_EXPORT_METHOD(registerForRemoteNotifications
326
335
  // Apple docs recommend that registerForRemoteNotifications is always called on app start
327
336
  // regardless of current status
328
337
  dispatch_async(dispatch_get_main_queue(), ^{
338
+ // Sometimes the registration never completes, which deserves separate attention in other
339
+ // areas. This area should protect itself against hanging forever regardless. Just in case,
340
+ // check in after a delay and cleanup if required
341
+ dispatch_after(
342
+ dispatch_time(DISPATCH_TIME_NOW, 10.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
343
+ if ([RNFBMessagingAppDelegate sharedInstance].registerPromiseResolver != nil) {
344
+ // if we got here and resolve/reject are still set, unset, log failure, reject
345
+ DLog(@"RNFBMessaging dispatch_after block: we appear to have timed out. Rejecting");
346
+ [[RNFBMessagingAppDelegate sharedInstance] setPromiseResolve:nil
347
+ andPromiseReject:nil];
348
+
349
+ [RNFBSharedUtils
350
+ rejectPromiseWithUserInfo:reject
351
+ userInfo:[@{
352
+ @"code" : @"unknown-error",
353
+ @"message" :
354
+ @"registerDeviceForRemoteMessages requested but "
355
+ @"system did not respond. Possibly missing permission."
356
+ } mutableCopy]];
357
+ return;
358
+ } else {
359
+ DLog(@"RNFBMessaging dispatch_after: registerDeviceForRemoteMessages handled.");
360
+ return;
361
+ }
362
+ });
363
+
329
364
  [[UIApplication sharedApplication] registerForRemoteNotifications];
330
365
  });
331
366
  }
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '19.2.2';
2
+ module.exports = '20.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/messaging",
3
- "version": "19.2.2",
3
+ "version": "20.0.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",
@@ -24,11 +24,11 @@
24
24
  "messaging"
25
25
  ],
26
26
  "peerDependencies": {
27
- "@react-native-firebase/app": "19.2.2",
27
+ "@react-native-firebase/app": "20.0.0",
28
28
  "expo": ">=47.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "expo": "^50.0.15"
31
+ "expo": "^50.0.18"
32
32
  },
33
33
  "peerDependenciesMeta": {
34
34
  "expo": {
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "2c1f48eacba95904c89073dcb391d89d0f966165"
41
+ "gitHead": "b6079dd09ed1f6e47dc782df0d98c5479bfc0cd4"
42
42
  }