@react-native-firebase/messaging 23.7.0 → 23.8.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/dist/commonjs/index.js +61 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/modular.js +439 -0
- package/dist/commonjs/modular.js.map +1 -0
- package/dist/commonjs/namespaced.js +407 -0
- package/dist/commonjs/namespaced.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/remoteMessageOptions.js +87 -0
- package/dist/commonjs/remoteMessageOptions.js.map +1 -0
- package/dist/commonjs/statics.js +29 -0
- package/dist/commonjs/statics.js.map +1 -0
- package/dist/commonjs/types/messaging.js +105 -0
- package/dist/commonjs/types/messaging.js.map +1 -0
- package/dist/commonjs/version.js +9 -0
- package/dist/commonjs/version.js.map +1 -0
- package/{ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.h → dist/module/index.js} +11 -12
- package/dist/module/index.js.map +1 -0
- package/{lib/modular/index.js → dist/module/modular.js} +135 -119
- package/dist/module/modular.js.map +1 -0
- package/{lib/index.js → dist/module/namespaced.js} +70 -193
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/{lib → dist/module}/remoteMessageOptions.js +10 -27
- package/dist/module/remoteMessageOptions.js.map +1 -0
- package/dist/module/statics.js +25 -0
- package/dist/module/statics.js.map +1 -0
- package/dist/module/types/messaging.js +124 -0
- package/dist/module/types/messaging.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/typescript/commonjs/lib/index.d.ts +6 -0
- package/dist/typescript/commonjs/lib/index.d.ts.map +1 -0
- package/{lib/modular/index.d.ts → dist/typescript/commonjs/lib/modular.d.ts} +86 -164
- package/dist/typescript/commonjs/lib/modular.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts +12 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts +14 -0
- package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/statics.d.ts +20 -0
- package/dist/typescript/commonjs/lib/statics.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/types/messaging.d.ts +673 -0
- package/dist/typescript/commonjs/lib/types/messaging.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/version.d.ts +2 -0
- package/dist/typescript/commonjs/lib/version.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/module/lib/index.d.ts +6 -0
- package/dist/typescript/module/lib/index.d.ts.map +1 -0
- package/dist/typescript/module/lib/modular.d.ts +247 -0
- package/dist/typescript/module/lib/modular.d.ts.map +1 -0
- package/dist/typescript/module/lib/namespaced.d.ts +12 -0
- package/dist/typescript/module/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/module/lib/remoteMessageOptions.d.ts +14 -0
- package/dist/typescript/module/lib/remoteMessageOptions.d.ts.map +1 -0
- package/dist/typescript/module/lib/statics.d.ts +20 -0
- package/dist/typescript/module/lib/statics.d.ts.map +1 -0
- package/dist/typescript/module/lib/types/messaging.d.ts +673 -0
- package/dist/typescript/module/lib/types/messaging.d.ts.map +1 -0
- package/dist/typescript/module/lib/version.d.ts +2 -0
- package/dist/typescript/module/lib/version.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/{ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.h → lib/index.ts} +28 -21
- package/lib/modular.ts +447 -0
- package/lib/namespaced.ts +583 -0
- package/lib/remoteMessageOptions.ts +110 -0
- package/lib/{statics.js → statics.ts} +6 -3
- package/lib/types/messaging.ts +815 -0
- package/lib/version.ts +2 -0
- package/package.json +64 -8
- package/tsconfig.json +21 -0
- package/CHANGELOG.md +0 -1181
- package/RNFBMessaging.podspec +0 -50
- package/android/.editorconfig +0 -10
- package/android/build.gradle +0 -149
- package/android/lint.xml +0 -5
- package/android/settings.gradle +0 -1
- package/android/src/main/AndroidManifest.xml +0 -43
- package/android/src/main/java/io/invertase/firebase/messaging/JsonConvert.java +0 -127
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingHeadlessService.java +0 -30
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingModule.java +0 -332
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingPackage.java +0 -41
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingReceiver.java +0 -66
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java +0 -225
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingService.java +0 -37
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStore.java +0 -15
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreHelper.java +0 -23
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreImpl.java +0 -97
- package/android/src/main/res/values/colors.xml +0 -143
- package/app.plugin.js +0 -1
- package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.h +0 -54
- package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m +0 -251
- package/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m +0 -70
- package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.h +0 -29
- package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.m +0 -173
- package/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +0 -185
- package/ios/RNFBMessaging/RNFBMessagingModule.h +0 -26
- package/ios/RNFBMessaging/RNFBMessagingModule.m +0 -431
- package/ios/RNFBMessaging/RNFBMessagingSerializer.h +0 -32
- package/ios/RNFBMessaging/RNFBMessagingSerializer.m +0 -235
- package/ios/RNFBMessaging.xcodeproj/project.pbxproj +0 -384
- package/ios/RNFBMessaging.xcodeproj/xcshareddata/IDETemplateMacros.plist +0 -24
- package/lib/index.d.ts +0 -1233
- package/lib/version.js +0 -2
- package/plugin/build/android/index.d.ts +0 -2
- package/plugin/build/android/index.js +0 -5
- package/plugin/build/android/setupFirebaseNotifationIcon.d.ts +0 -8
- package/plugin/build/android/setupFirebaseNotifationIcon.js +0 -62
- package/plugin/build/index.d.ts +0 -3
- package/plugin/build/index.js +0 -16
- package/plugin/tsconfig.tsbuildinfo +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
#import <GoogleUtilities/GULAppDelegateSwizzler.h>
|
|
19
|
-
#import <RNFBApp/RNFBRCTEventEmitter.h>
|
|
20
|
-
#import <objc/message.h>
|
|
21
|
-
#import <objc/runtime.h>
|
|
22
|
-
|
|
23
|
-
#import "RNFBMessaging+FIRMessagingDelegate.h"
|
|
24
|
-
#import "RNFBMessagingSerializer.h"
|
|
25
|
-
|
|
26
|
-
@implementation RNFBMessagingFIRMessagingDelegate
|
|
27
|
-
|
|
28
|
-
+ (instancetype)sharedInstance {
|
|
29
|
-
static dispatch_once_t once;
|
|
30
|
-
__strong static RNFBMessagingFIRMessagingDelegate *sharedInstance;
|
|
31
|
-
dispatch_once(&once, ^{
|
|
32
|
-
sharedInstance = [[RNFBMessagingFIRMessagingDelegate alloc] init];
|
|
33
|
-
});
|
|
34
|
-
return sharedInstance;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (void)observe {
|
|
38
|
-
static dispatch_once_t once;
|
|
39
|
-
__weak RNFBMessagingFIRMessagingDelegate *weakSelf = self;
|
|
40
|
-
dispatch_once(&once, ^{
|
|
41
|
-
RNFBMessagingFIRMessagingDelegate *strongSelf = weakSelf;
|
|
42
|
-
[FIRMessaging messaging].delegate = strongSelf;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
#pragma mark -
|
|
47
|
-
#pragma mark FIRMessagingDelegate Methods
|
|
48
|
-
|
|
49
|
-
// JS -> `onTokenRefresh`
|
|
50
|
-
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
|
|
51
|
-
if (fcmToken == nil) { // Don't crash when the token is reset
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_token_refresh"
|
|
55
|
-
body:@{@"token" : fcmToken}];
|
|
56
|
-
|
|
57
|
-
// If the users AppDelegate implements messaging:didReceiveRegistrationToken: then call it
|
|
58
|
-
SEL messaging_didReceiveRegistrationTokenSelector =
|
|
59
|
-
NSSelectorFromString(@"messaging:didReceiveRegistrationToken:");
|
|
60
|
-
if ([[GULAppDelegateSwizzler sharedApplication].delegate
|
|
61
|
-
respondsToSelector:messaging_didReceiveRegistrationTokenSelector]) {
|
|
62
|
-
void (*usersDidReceiveRegistrationTokenIMP)(id, SEL, FIRMessaging *, NSString *) =
|
|
63
|
-
(typeof(usersDidReceiveRegistrationTokenIMP))&objc_msgSend;
|
|
64
|
-
usersDidReceiveRegistrationTokenIMP([GULAppDelegateSwizzler sharedApplication].delegate,
|
|
65
|
-
messaging_didReceiveRegistrationTokenSelector, messaging,
|
|
66
|
-
fcmToken);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
#import <Foundation/Foundation.h>
|
|
19
|
-
|
|
20
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
21
|
-
|
|
22
|
-
@interface RNFBMessagingNSNotificationCenter : NSObject
|
|
23
|
-
|
|
24
|
-
+ (_Nonnull instancetype)sharedInstance;
|
|
25
|
-
@property(nonatomic) BOOL isHeadless;
|
|
26
|
-
|
|
27
|
-
@end
|
|
28
|
-
|
|
29
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
#import <Firebase/Firebase.h>
|
|
18
|
-
#import <RNFBApp/RNFBJSON.h>
|
|
19
|
-
#import <RNFBApp/RNFBRCTEventEmitter.h>
|
|
20
|
-
#import <React/RCTConvert.h>
|
|
21
|
-
#import <React/RCTRootView.h>
|
|
22
|
-
|
|
23
|
-
#import "RNFBMessaging+AppDelegate.h"
|
|
24
|
-
#import "RNFBMessaging+FIRMessagingDelegate.h"
|
|
25
|
-
#import "RNFBMessaging+NSNotificationCenter.h"
|
|
26
|
-
#import "RNFBMessaging+UNUserNotificationCenter.h"
|
|
27
|
-
|
|
28
|
-
@implementation RNFBMessagingNSNotificationCenter
|
|
29
|
-
@synthesize isHeadless;
|
|
30
|
-
+ (instancetype)sharedInstance {
|
|
31
|
-
static dispatch_once_t once;
|
|
32
|
-
__strong static RNFBMessagingNSNotificationCenter *sharedInstance;
|
|
33
|
-
dispatch_once(&once, ^{
|
|
34
|
-
sharedInstance = [[RNFBMessagingNSNotificationCenter alloc] init];
|
|
35
|
-
});
|
|
36
|
-
return sharedInstance;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
- (void)observe {
|
|
40
|
-
static dispatch_once_t once;
|
|
41
|
-
__weak RNFBMessagingNSNotificationCenter *weakSelf = self;
|
|
42
|
-
dispatch_once(&once, ^{
|
|
43
|
-
RNFBMessagingNSNotificationCenter *strongSelf = weakSelf;
|
|
44
|
-
|
|
45
|
-
// Application
|
|
46
|
-
// JS -> `getInitialNotification`
|
|
47
|
-
// ObjC -> Initialize other delegates & observers
|
|
48
|
-
[[NSNotificationCenter defaultCenter]
|
|
49
|
-
addObserver:strongSelf
|
|
50
|
-
selector:@selector(application_onDidFinishLaunchingNotification:)
|
|
51
|
-
name:UIApplicationDidFinishLaunchingNotification
|
|
52
|
-
object:nil];
|
|
53
|
-
|
|
54
|
-
// Application
|
|
55
|
-
// ObjC - > Mutates the root React components initialProps to toggle `isHeadless` state
|
|
56
|
-
[[NSNotificationCenter defaultCenter] addObserver:strongSelf
|
|
57
|
-
selector:@selector(application_onDidEnterForeground)
|
|
58
|
-
name:UIApplicationWillEnterForegroundNotification
|
|
59
|
-
object:nil];
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// start observing immediately on class load - specifically for
|
|
64
|
-
// UIApplicationDidFinishLaunchingNotification
|
|
65
|
-
+ (void)load {
|
|
66
|
-
[[self sharedInstance] observe];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#pragma mark -
|
|
70
|
-
#pragma mark Application Notifications
|
|
71
|
-
|
|
72
|
-
- (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)notification {
|
|
73
|
-
// setup our delegates & swizzling after app finishes launching
|
|
74
|
-
// these methods are idempotent so can safely be called multiple times
|
|
75
|
-
[[RNFBMessagingAppDelegate sharedInstance] observe];
|
|
76
|
-
[[RNFBMessagingUNUserNotificationCenter sharedInstance] observe];
|
|
77
|
-
[[RNFBMessagingFIRMessagingDelegate sharedInstance] observe];
|
|
78
|
-
|
|
79
|
-
RCTRootView *rctRootView;
|
|
80
|
-
if ([UIApplication sharedApplication].delegate != nil &&
|
|
81
|
-
[UIApplication sharedApplication].delegate.window != nil &&
|
|
82
|
-
[UIApplication sharedApplication].delegate.window.rootViewController != nil &&
|
|
83
|
-
[UIApplication sharedApplication].delegate.window.rootViewController.view != nil &&
|
|
84
|
-
[[UIApplication sharedApplication].delegate.window.rootViewController.view
|
|
85
|
-
isKindOfClass:[RCTRootView class]]) {
|
|
86
|
-
rctRootView =
|
|
87
|
-
(RCTRootView *)[UIApplication sharedApplication].delegate.window.rootViewController.view;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// #if !(TARGET_IPHONE_SIMULATOR)
|
|
91
|
-
if ([[RNFBJSON shared] getBooleanValue:@"messaging_ios_auto_register_for_remote_messages"
|
|
92
|
-
defaultValue:YES]) {
|
|
93
|
-
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
|
94
|
-
}
|
|
95
|
-
// #endif
|
|
96
|
-
|
|
97
|
-
if (notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
|
98
|
-
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
|
99
|
-
isHeadless = YES;
|
|
100
|
-
if (rctRootView != nil) {
|
|
101
|
-
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
|
102
|
-
? [rctRootView.appProperties mutableCopy]
|
|
103
|
-
: [NSMutableDictionary dictionary];
|
|
104
|
-
if ([appPropertiesDict objectForKey:@"isHeadless"] != nil &&
|
|
105
|
-
[appPropertiesDict[@"isHeadless"] isEqual:@([RCTConvert BOOL:@(NO)])]) {
|
|
106
|
-
appPropertiesDict[@"isHeadless"] = @([RCTConvert BOOL:@(isHeadless)]);
|
|
107
|
-
rctRootView.appProperties = appPropertiesDict;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// #if !(TARGET_IPHONE_SIMULATOR)
|
|
112
|
-
// When an app launches in the background (BG mode) and is launched with the notification
|
|
113
|
-
// launch option the app delegate method
|
|
114
|
-
// application:didReceiveRemoteNotification:fetchCompletionHandler: will not get called unless
|
|
115
|
-
// registerForRemoteNotifications was called early during app initialization - we call it here
|
|
116
|
-
// in this scenario as the user can only call this via JS, at which point it'd be too late
|
|
117
|
-
// resulting in the app being terminated. called irregardless of
|
|
118
|
-
// `messaging_ios_auto_register_for_remote_messages` as this is most likely an app launching
|
|
119
|
-
// as a result of a remote notification - so has been registered previously
|
|
120
|
-
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
|
121
|
-
// #endif
|
|
122
|
-
} else {
|
|
123
|
-
isHeadless = NO;
|
|
124
|
-
if (rctRootView != nil) {
|
|
125
|
-
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
|
126
|
-
? [rctRootView.appProperties mutableCopy]
|
|
127
|
-
: [NSMutableDictionary dictionary];
|
|
128
|
-
if ([appPropertiesDict objectForKey:@"isHeadless"] != nil &&
|
|
129
|
-
[appPropertiesDict[@"isHeadless"] isEqual:@([RCTConvert BOOL:@(YES)])]) {
|
|
130
|
-
appPropertiesDict[@"isHeadless"] = @([RCTConvert BOOL:@(isHeadless)]);
|
|
131
|
-
rctRootView.appProperties = appPropertiesDict;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
isHeadless = NO;
|
|
137
|
-
if (rctRootView != nil) {
|
|
138
|
-
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
|
139
|
-
? [rctRootView.appProperties mutableCopy]
|
|
140
|
-
: [NSMutableDictionary dictionary];
|
|
141
|
-
if ([appPropertiesDict objectForKey:@"isHeadless"] != nil &&
|
|
142
|
-
[appPropertiesDict[@"isHeadless"] isEqual:@([RCTConvert BOOL:@(YES)])]) {
|
|
143
|
-
appPropertiesDict[@"isHeadless"] = @([RCTConvert BOOL:@(isHeadless)]);
|
|
144
|
-
rctRootView.appProperties = appPropertiesDict;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
- (void)application_onDidEnterForeground {
|
|
151
|
-
isHeadless = NO;
|
|
152
|
-
if ([UIApplication sharedApplication].delegate != nil &&
|
|
153
|
-
[UIApplication sharedApplication].delegate.window != nil &&
|
|
154
|
-
[UIApplication sharedApplication].delegate.window.rootViewController != nil &&
|
|
155
|
-
[UIApplication sharedApplication].delegate.window.rootViewController.view != nil &&
|
|
156
|
-
[[UIApplication sharedApplication].delegate.window.rootViewController.view
|
|
157
|
-
isKindOfClass:[RCTRootView class]]) {
|
|
158
|
-
RCTRootView *rctRootView =
|
|
159
|
-
(RCTRootView *)[UIApplication sharedApplication].delegate.window.rootViewController.view;
|
|
160
|
-
|
|
161
|
-
if (rctRootView.appProperties != nil &&
|
|
162
|
-
[rctRootView.appProperties[@"isHeadless"] isEqual:@(YES)]) {
|
|
163
|
-
NSMutableDictionary *appPropertiesDict = [rctRootView.appProperties mutableCopy];
|
|
164
|
-
if ([appPropertiesDict objectForKey:@"isHeadless"] != nil &&
|
|
165
|
-
[appPropertiesDict[@"isHeadless"] isEqual:@([RCTConvert BOOL:@(YES)])]) {
|
|
166
|
-
appPropertiesDict[@"isHeadless"] = @([RCTConvert BOOL:@(isHeadless)]);
|
|
167
|
-
rctRootView.appProperties = appPropertiesDict;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@end
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
#import <RNFBApp/RNFBRCTEventEmitter.h>
|
|
19
|
-
|
|
20
|
-
#import "RNFBJSON.h"
|
|
21
|
-
#import "RNFBMessaging+UNUserNotificationCenter.h"
|
|
22
|
-
#import "RNFBMessagingSerializer.h"
|
|
23
|
-
|
|
24
|
-
@implementation RNFBMessagingUNUserNotificationCenter
|
|
25
|
-
struct {
|
|
26
|
-
unsigned int willPresentNotification : 1;
|
|
27
|
-
unsigned int didReceiveNotificationResponse : 1;
|
|
28
|
-
unsigned int openSettingsForNotification : 1;
|
|
29
|
-
} originalDelegateRespondsTo;
|
|
30
|
-
|
|
31
|
-
+ (instancetype)sharedInstance {
|
|
32
|
-
static dispatch_once_t once;
|
|
33
|
-
__strong static RNFBMessagingUNUserNotificationCenter *sharedInstance;
|
|
34
|
-
dispatch_once(&once, ^{
|
|
35
|
-
sharedInstance = [[RNFBMessagingUNUserNotificationCenter alloc] init];
|
|
36
|
-
sharedInstance.initialNotification = nil;
|
|
37
|
-
sharedInstance.didOpenSettingsForNotification = NO;
|
|
38
|
-
});
|
|
39
|
-
return sharedInstance;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (void)observe {
|
|
43
|
-
static dispatch_once_t once;
|
|
44
|
-
__weak RNFBMessagingUNUserNotificationCenter *weakSelf = self;
|
|
45
|
-
dispatch_once(&once, ^{
|
|
46
|
-
RNFBMessagingUNUserNotificationCenter *strongSelf = weakSelf;
|
|
47
|
-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
48
|
-
if (center.delegate != nil) {
|
|
49
|
-
_originalDelegate = center.delegate;
|
|
50
|
-
originalDelegateRespondsTo.openSettingsForNotification = (unsigned int)[_originalDelegate
|
|
51
|
-
respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)];
|
|
52
|
-
originalDelegateRespondsTo.willPresentNotification = (unsigned int)[_originalDelegate
|
|
53
|
-
respondsToSelector:@selector(userNotificationCenter:
|
|
54
|
-
willPresentNotification:withCompletionHandler:)];
|
|
55
|
-
originalDelegateRespondsTo.didReceiveNotificationResponse = (unsigned int)[_originalDelegate
|
|
56
|
-
respondsToSelector:@selector(userNotificationCenter:
|
|
57
|
-
didReceiveNotificationResponse:withCompletionHandler:)];
|
|
58
|
-
}
|
|
59
|
-
center.delegate = strongSelf;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
- (nullable NSDictionary *)getInitialNotification {
|
|
64
|
-
if (_initialNotification != nil) {
|
|
65
|
-
NSDictionary *initialNotificationCopy = [_initialNotification copy];
|
|
66
|
-
_initialNotification = nil;
|
|
67
|
-
return initialNotificationCopy;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return nil;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
- (NSNumber *)getDidOpenSettingsForNotification {
|
|
74
|
-
if (_didOpenSettingsForNotification != NO) {
|
|
75
|
-
_didOpenSettingsForNotification = NO;
|
|
76
|
-
return @YES;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return @NO;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
83
|
-
willPresentNotification:(UNNotification *)notification
|
|
84
|
-
withCompletionHandler:
|
|
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
|
-
|
|
130
|
-
if (notification.request.content.userInfo[@"gcm.message_id"]) {
|
|
131
|
-
NSDictionary *notificationDict = [RNFBMessagingSerializer notificationToDict:notification];
|
|
132
|
-
|
|
133
|
-
// Don't send an event if contentAvailable is true - application:didReceiveRemoteNotification
|
|
134
|
-
// will send the event for us, we don't want to duplicate them
|
|
135
|
-
if (!notificationDict[@"contentAvailable"]) {
|
|
136
|
-
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_message_received"
|
|
137
|
-
body:notificationDict];
|
|
138
|
-
}
|
|
139
|
-
completionHandler(presentationOptions);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (_originalDelegate != nil && originalDelegateRespondsTo.willPresentNotification) {
|
|
143
|
-
[_originalDelegate userNotificationCenter:center
|
|
144
|
-
willPresentNotification:notification
|
|
145
|
-
withCompletionHandler:completionHandler];
|
|
146
|
-
} else {
|
|
147
|
-
completionHandler(presentationOptions);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
152
|
-
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
153
|
-
withCompletionHandler:(void (^)(void))completionHandler {
|
|
154
|
-
NSDictionary *remoteNotification = response.notification.request.content.userInfo;
|
|
155
|
-
if (remoteNotification[@"gcm.message_id"]) {
|
|
156
|
-
NSDictionary *notificationDict =
|
|
157
|
-
[RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification];
|
|
158
|
-
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened"
|
|
159
|
-
body:notificationDict];
|
|
160
|
-
_initialNotification = notificationDict;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) {
|
|
164
|
-
[_originalDelegate userNotificationCenter:center
|
|
165
|
-
didReceiveNotificationResponse:response
|
|
166
|
-
withCompletionHandler:completionHandler];
|
|
167
|
-
} else {
|
|
168
|
-
completionHandler();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
173
|
-
openSettingsForNotification:(nullable UNNotification *)notification {
|
|
174
|
-
if (_originalDelegate != nil && originalDelegateRespondsTo.openSettingsForNotification) {
|
|
175
|
-
[_originalDelegate userNotificationCenter:center openSettingsForNotification:notification];
|
|
176
|
-
} else {
|
|
177
|
-
NSDictionary *notificationDict = [RNFBMessagingSerializer notificationToDict:notification];
|
|
178
|
-
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_settings_for_notification_opened"
|
|
179
|
-
body:notificationDict];
|
|
180
|
-
|
|
181
|
-
_didOpenSettingsForNotification = YES;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
@end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
#import <Foundation/Foundation.h>
|
|
19
|
-
#import <React/RCTBridgeModule.h>
|
|
20
|
-
|
|
21
|
-
@interface RNFBMessagingModule : NSObject <RCTBridgeModule>
|
|
22
|
-
+ (NSDictionary *_Nonnull)addCustomPropsToUserProps:(NSDictionary *_Nullable)userProps
|
|
23
|
-
withLaunchOptions:(NSDictionary *_Nullable)launchOptions;
|
|
24
|
-
@property BOOL isDeliveryMetricsExportToBigQueryEnabled;
|
|
25
|
-
|
|
26
|
-
@end
|