@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
package/RNFBMessaging.podspec
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
|
-
appPackage = JSON.parse(File.read(File.join('..', 'app', 'package.json')))
|
|
4
|
-
|
|
5
|
-
coreVersionDetected = appPackage['version']
|
|
6
|
-
coreVersionRequired = package['peerDependencies'][appPackage['name']]
|
|
7
|
-
firebase_sdk_version = appPackage['sdkVersions']['ios']['firebase']
|
|
8
|
-
if coreVersionDetected != coreVersionRequired
|
|
9
|
-
Pod::UI.warn "NPM package '#{package['name']}' depends on '#{appPackage['name']}' v#{coreVersionRequired} but found v#{coreVersionDetected}, this might cause build issues or runtime crashes."
|
|
10
|
-
end
|
|
11
|
-
firebase_ios_target = appPackage['sdkVersions']['ios']['iosTarget']
|
|
12
|
-
firebase_macos_target = appPackage['sdkVersions']['ios']['macosTarget']
|
|
13
|
-
|
|
14
|
-
Pod::Spec.new do |s|
|
|
15
|
-
s.name = "RNFBMessaging"
|
|
16
|
-
s.version = package["version"]
|
|
17
|
-
s.description = package["description"]
|
|
18
|
-
s.summary = <<-DESC
|
|
19
|
-
A well tested feature rich Firebase implementation for React Native, supporting iOS & Android.
|
|
20
|
-
DESC
|
|
21
|
-
s.homepage = "http://invertase.io/oss/react-native-firebase"
|
|
22
|
-
s.license = package['license']
|
|
23
|
-
s.authors = "Invertase Limited"
|
|
24
|
-
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
|
|
25
|
-
s.social_media_url = 'http://twitter.com/invertaseio'
|
|
26
|
-
s.ios.deployment_target = firebase_ios_target
|
|
27
|
-
s.macos.deployment_target = firebase_macos_target
|
|
28
|
-
s.source_files = 'ios/**/*.{h,m}'
|
|
29
|
-
|
|
30
|
-
# React Native dependencies
|
|
31
|
-
s.dependency 'React-Core'
|
|
32
|
-
s.dependency 'RNFBApp'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if defined?($FirebaseSDKVersion)
|
|
36
|
-
Pod::UI.puts "#{s.name}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
|
|
37
|
-
firebase_sdk_version = $FirebaseSDKVersion
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Firebase dependencies
|
|
41
|
-
s.dependency 'Firebase/Messaging', firebase_sdk_version
|
|
42
|
-
s.dependency 'FirebaseCoreExtension'
|
|
43
|
-
|
|
44
|
-
if defined?($RNFirebaseAsStaticFramework)
|
|
45
|
-
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
|
|
46
|
-
s.static_framework = $RNFirebaseAsStaticFramework
|
|
47
|
-
else
|
|
48
|
-
s.static_framework = false
|
|
49
|
-
end
|
|
50
|
-
end
|
package/android/.editorconfig
DELETED
package/android/build.gradle
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import io.invertase.gradle.common.PackageJson
|
|
2
|
-
|
|
3
|
-
buildscript {
|
|
4
|
-
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
5
|
-
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
6
|
-
// module dependency in an application project.
|
|
7
|
-
if (project == rootProject) {
|
|
8
|
-
repositories {
|
|
9
|
-
google()
|
|
10
|
-
mavenCentral()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
dependencies {
|
|
14
|
-
classpath("com.android.tools.build:gradle:8.4.0")
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
plugins {
|
|
20
|
-
id "io.invertase.gradle.build" version "1.5"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
def appProject
|
|
24
|
-
if (findProject(':@react-native-firebase_app')) {
|
|
25
|
-
appProject = project(':@react-native-firebase_app')
|
|
26
|
-
} else if (findProject(':react-native-firebase_app')) {
|
|
27
|
-
appProject = project(':react-native-firebase_app')
|
|
28
|
-
} else {
|
|
29
|
-
throw new GradleException('Could not find the react-native-firebase/app package, have you installed it?')
|
|
30
|
-
}
|
|
31
|
-
def packageJson = PackageJson.getForProject(project)
|
|
32
|
-
def appPackageJson = PackageJson.getForProject(appProject)
|
|
33
|
-
def firebaseBomVersion = appPackageJson['sdkVersions']['android']['firebase']
|
|
34
|
-
def jsonMinSdk = appPackageJson['sdkVersions']['android']['minSdk']
|
|
35
|
-
def jsonTargetSdk = appPackageJson['sdkVersions']['android']['targetSdk']
|
|
36
|
-
def jsonCompileSdk = appPackageJson['sdkVersions']['android']['compileSdk']
|
|
37
|
-
def coreVersionDetected = appPackageJson['version']
|
|
38
|
-
def coreVersionRequired = packageJson['peerDependencies'][appPackageJson['name']]
|
|
39
|
-
if (coreVersionDetected != coreVersionRequired) {
|
|
40
|
-
project.logger.warn("ReactNativeFirebase WARNING: NPM package '${packageJson['name']}' depends on '${appPackageJson['name']}' v${coreVersionRequired} but found v${coreVersionDetected}, this might cause build issues or runtime crashes.")
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
project.ext {
|
|
44
|
-
set('react-native', [
|
|
45
|
-
versions: [
|
|
46
|
-
android : [
|
|
47
|
-
minSdk : jsonMinSdk,
|
|
48
|
-
targetSdk : jsonTargetSdk,
|
|
49
|
-
compileSdk: jsonCompileSdk,
|
|
50
|
-
],
|
|
51
|
-
|
|
52
|
-
firebase: [
|
|
53
|
-
bom: firebaseBomVersion,
|
|
54
|
-
],
|
|
55
|
-
],
|
|
56
|
-
])
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
apply from: file('./../../app/android/firebase-json.gradle')
|
|
60
|
-
|
|
61
|
-
String defaultNotificationChannelId = ''
|
|
62
|
-
String notificationChannelId = defaultNotificationChannelId
|
|
63
|
-
String defaultNotificationColor = '@color/white'
|
|
64
|
-
String notificationColor = defaultNotificationColor
|
|
65
|
-
|
|
66
|
-
String deliveryMetricsExportEnabled = 'false'
|
|
67
|
-
|
|
68
|
-
// If nothing is defined, data collection defaults to true
|
|
69
|
-
String dataCollectionEnabled = 'true'
|
|
70
|
-
|
|
71
|
-
String notificationDelegationEnabled = 'false'
|
|
72
|
-
|
|
73
|
-
if (rootProject.ext && rootProject.ext.firebaseJson) {
|
|
74
|
-
/* groovylint-disable-next-line NoDef, VariableTypeRequired */
|
|
75
|
-
def rnfbConfig = rootProject.ext.firebaseJson
|
|
76
|
-
// If the SDK-wide data collection flag is defined and false, our default flips to false
|
|
77
|
-
if (rnfbConfig.isFlagEnabled('app_data_collection_default_enabled', true) == false) {
|
|
78
|
-
dataCollectionEnabled = 'false'
|
|
79
|
-
}
|
|
80
|
-
// If our specific collection flag is defined, it's status takes precedence
|
|
81
|
-
if (rnfbConfig.isDefined('messaging_auto_init_enabled')) {
|
|
82
|
-
if (rnfbConfig.isFlagEnabled('messaging_auto_init_enabled', true)) {
|
|
83
|
-
dataCollectionEnabled = 'true'
|
|
84
|
-
} else {
|
|
85
|
-
dataCollectionEnabled = 'false'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (rnfbConfig.isFlagEnabled('messaging_android_notification_delivery_metrics_export_enabled', false)) {
|
|
90
|
-
deliveryMetricsExportEnabled = 'true'
|
|
91
|
-
}
|
|
92
|
-
notificationChannelId = rnfbConfig.getStringValue('messaging_android_notification_channel_id', defaultNotificationChannelId)
|
|
93
|
-
notificationColor = rnfbConfig.getStringValue('messaging_android_notification_color', defaultNotificationColor)
|
|
94
|
-
|
|
95
|
-
if (rnfbConfig.isFlagEnabled('messaging_android_notification_delegation_enabled', false)) {
|
|
96
|
-
notificationDelegationEnabled = 'true'
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
android {
|
|
101
|
-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
|
|
102
|
-
if (agpVersion >= 7) {
|
|
103
|
-
namespace = 'io.invertase.firebase.messaging'
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
defaultConfig {
|
|
107
|
-
multiDexEnabled = true
|
|
108
|
-
manifestPlaceholders = [
|
|
109
|
-
firebaseJsonDeliveryMetricsExportEnabled: deliveryMetricsExportEnabled,
|
|
110
|
-
firebaseJsonAutoInitEnabled: dataCollectionEnabled,
|
|
111
|
-
firebaseJsonNotificationChannelId: notificationChannelId,
|
|
112
|
-
firebaseJsonNotificationColor: notificationColor,
|
|
113
|
-
firebaseJsonNotificationDelegationEnabled: notificationDelegationEnabled
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
buildFeatures {
|
|
118
|
-
// AGP 8 no longer builds config by default
|
|
119
|
-
buildConfig = true
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
lintOptions {
|
|
123
|
-
disable 'GradleCompatible'
|
|
124
|
-
abortOnError = false
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (agpVersion < 8) {
|
|
128
|
-
compileOptions {
|
|
129
|
-
sourceCompatibility = JavaVersion.VERSION_11
|
|
130
|
-
targetCompatibility = JavaVersion.VERSION_11
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
repositories {
|
|
136
|
-
google()
|
|
137
|
-
mavenCentral()
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
dependencies {
|
|
141
|
-
api appProject
|
|
142
|
-
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
|
|
143
|
-
implementation "com.google.firebase:firebase-messaging"
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
ReactNative.shared.applyPackageVersion()
|
|
147
|
-
ReactNative.shared.applyDefaultExcludes()
|
|
148
|
-
ReactNative.module.applyAndroidVersions()
|
|
149
|
-
ReactNative.module.applyReactNativeDependency("api")
|
package/android/lint.xml
DELETED
package/android/settings.gradle
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
rootProject.name = '@react-native-firebase_messaging'
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
package="io.invertase.firebase.messaging">
|
|
4
|
-
|
|
5
|
-
<uses-permission android:name="android.permission.INTERNET"/>
|
|
6
|
-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
7
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
8
|
-
|
|
9
|
-
<application>
|
|
10
|
-
<service android:name=".ReactNativeFirebaseMessagingHeadlessService"
|
|
11
|
-
android:exported="false" />
|
|
12
|
-
<service android:name=".ReactNativeFirebaseMessagingService"
|
|
13
|
-
android:exported="false">
|
|
14
|
-
<intent-filter>
|
|
15
|
-
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
16
|
-
</intent-filter>
|
|
17
|
-
</service>
|
|
18
|
-
<receiver
|
|
19
|
-
android:name=".ReactNativeFirebaseMessagingReceiver"
|
|
20
|
-
android:exported="true"
|
|
21
|
-
android:permission="com.google.android.c2dm.permission.SEND">
|
|
22
|
-
<intent-filter>
|
|
23
|
-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
|
24
|
-
</intent-filter>
|
|
25
|
-
</receiver>
|
|
26
|
-
|
|
27
|
-
<meta-data
|
|
28
|
-
android:name= "delivery_metrics_exported_to_big_query_enabled"
|
|
29
|
-
android:value="${firebaseJsonDeliveryMetricsExportEnabled}"/>
|
|
30
|
-
<meta-data
|
|
31
|
-
android:name="firebase_messaging_auto_init_enabled"
|
|
32
|
-
android:value="${firebaseJsonAutoInitEnabled}"/>
|
|
33
|
-
<meta-data
|
|
34
|
-
android:name="firebase_messaging_notification_delegation_enabled"
|
|
35
|
-
android:value="${firebaseJsonNotificationDelegationEnabled}"/>
|
|
36
|
-
<meta-data
|
|
37
|
-
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
|
38
|
-
android:value="${firebaseJsonNotificationChannelId}" />
|
|
39
|
-
<meta-data
|
|
40
|
-
android:name="com.google.firebase.messaging.default_notification_color"
|
|
41
|
-
android:resource="${firebaseJsonNotificationColor}" />
|
|
42
|
-
</application>
|
|
43
|
-
</manifest>
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.messaging;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Arguments;
|
|
4
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
7
|
-
import com.facebook.react.bridge.ReadableType;
|
|
8
|
-
import com.facebook.react.bridge.WritableArray;
|
|
9
|
-
import com.facebook.react.bridge.WritableMap;
|
|
10
|
-
import java.util.Iterator;
|
|
11
|
-
import org.json.JSONArray;
|
|
12
|
-
import org.json.JSONException;
|
|
13
|
-
import org.json.JSONObject;
|
|
14
|
-
|
|
15
|
-
public abstract class JsonConvert {
|
|
16
|
-
public static JSONObject reactToJSON(ReadableMap readableMap) throws JSONException {
|
|
17
|
-
JSONObject jsonObject = new JSONObject();
|
|
18
|
-
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
19
|
-
while (iterator.hasNextKey()) {
|
|
20
|
-
String key = iterator.nextKey();
|
|
21
|
-
ReadableType valueType = readableMap.getType(key);
|
|
22
|
-
switch (valueType) {
|
|
23
|
-
case Null:
|
|
24
|
-
jsonObject.put(key, JSONObject.NULL);
|
|
25
|
-
break;
|
|
26
|
-
case Boolean:
|
|
27
|
-
jsonObject.put(key, readableMap.getBoolean(key));
|
|
28
|
-
break;
|
|
29
|
-
case Number:
|
|
30
|
-
try {
|
|
31
|
-
jsonObject.put(key, readableMap.getInt(key));
|
|
32
|
-
} catch (Exception e) {
|
|
33
|
-
jsonObject.put(key, readableMap.getDouble(key));
|
|
34
|
-
}
|
|
35
|
-
break;
|
|
36
|
-
case String:
|
|
37
|
-
jsonObject.put(key, readableMap.getString(key));
|
|
38
|
-
break;
|
|
39
|
-
case Map:
|
|
40
|
-
jsonObject.put(key, reactToJSON(readableMap.getMap(key)));
|
|
41
|
-
break;
|
|
42
|
-
case Array:
|
|
43
|
-
jsonObject.put(key, reactToJSON(readableMap.getArray(key)));
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return jsonObject;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public static JSONArray reactToJSON(ReadableArray readableArray) throws JSONException {
|
|
52
|
-
JSONArray jsonArray = new JSONArray();
|
|
53
|
-
for (int i = 0; i < readableArray.size(); i++) {
|
|
54
|
-
ReadableType valueType = readableArray.getType(i);
|
|
55
|
-
switch (valueType) {
|
|
56
|
-
case Null:
|
|
57
|
-
jsonArray.put(JSONObject.NULL);
|
|
58
|
-
break;
|
|
59
|
-
case Boolean:
|
|
60
|
-
jsonArray.put(readableArray.getBoolean(i));
|
|
61
|
-
break;
|
|
62
|
-
case Number:
|
|
63
|
-
try {
|
|
64
|
-
jsonArray.put(readableArray.getInt(i));
|
|
65
|
-
} catch (Exception e) {
|
|
66
|
-
jsonArray.put(readableArray.getDouble(i));
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
69
|
-
case String:
|
|
70
|
-
jsonArray.put(readableArray.getString(i));
|
|
71
|
-
break;
|
|
72
|
-
case Map:
|
|
73
|
-
jsonArray.put(reactToJSON(readableArray.getMap(i)));
|
|
74
|
-
break;
|
|
75
|
-
case Array:
|
|
76
|
-
jsonArray.put(reactToJSON(readableArray.getArray(i)));
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return jsonArray;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public static WritableMap jsonToReact(JSONObject jsonObject) throws JSONException {
|
|
84
|
-
WritableMap writableMap = Arguments.createMap();
|
|
85
|
-
Iterator iterator = jsonObject.keys();
|
|
86
|
-
while (iterator.hasNext()) {
|
|
87
|
-
String key = (String) iterator.next();
|
|
88
|
-
Object value = jsonObject.get(key);
|
|
89
|
-
if (value instanceof Float || value instanceof Double) {
|
|
90
|
-
writableMap.putDouble(key, jsonObject.getDouble(key));
|
|
91
|
-
} else if (value instanceof Number) {
|
|
92
|
-
writableMap.putInt(key, jsonObject.getInt(key));
|
|
93
|
-
} else if (value instanceof String) {
|
|
94
|
-
writableMap.putString(key, jsonObject.getString(key));
|
|
95
|
-
} else if (value instanceof JSONObject) {
|
|
96
|
-
writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key)));
|
|
97
|
-
} else if (value instanceof JSONArray) {
|
|
98
|
-
writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
|
|
99
|
-
} else if (value == JSONObject.NULL) {
|
|
100
|
-
writableMap.putNull(key);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return writableMap;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public static WritableArray jsonToReact(JSONArray jsonArray) throws JSONException {
|
|
108
|
-
WritableArray writableArray = Arguments.createArray();
|
|
109
|
-
for (int i = 0; i < jsonArray.length(); i++) {
|
|
110
|
-
Object value = jsonArray.get(i);
|
|
111
|
-
if (value instanceof Float || value instanceof Double) {
|
|
112
|
-
writableArray.pushDouble(jsonArray.getDouble(i));
|
|
113
|
-
} else if (value instanceof Number) {
|
|
114
|
-
writableArray.pushInt(jsonArray.getInt(i));
|
|
115
|
-
} else if (value instanceof String) {
|
|
116
|
-
writableArray.pushString(jsonArray.getString(i));
|
|
117
|
-
} else if (value instanceof JSONObject) {
|
|
118
|
-
writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)));
|
|
119
|
-
} else if (value instanceof JSONArray) {
|
|
120
|
-
writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)));
|
|
121
|
-
} else if (value == JSONObject.NULL) {
|
|
122
|
-
writableArray.pushNull();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return writableArray;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.messaging;
|
|
2
|
-
|
|
3
|
-
import android.content.Intent;
|
|
4
|
-
import android.os.Bundle;
|
|
5
|
-
import com.facebook.react.HeadlessJsTaskService;
|
|
6
|
-
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
|
|
7
|
-
import com.google.firebase.messaging.RemoteMessage;
|
|
8
|
-
import io.invertase.firebase.common.ReactNativeFirebaseJSON;
|
|
9
|
-
import javax.annotation.Nullable;
|
|
10
|
-
|
|
11
|
-
public class ReactNativeFirebaseMessagingHeadlessService extends HeadlessJsTaskService {
|
|
12
|
-
private static final long TIMEOUT_DEFAULT = 60000;
|
|
13
|
-
private static final String TIMEOUT_JSON_KEY = "messaging_android_headless_task_timeout";
|
|
14
|
-
private static final String TASK_KEY = "ReactNativeFirebaseMessagingHeadlessTask";
|
|
15
|
-
|
|
16
|
-
@Override
|
|
17
|
-
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
|
|
18
|
-
Bundle extras = intent.getExtras();
|
|
19
|
-
if (extras == null) return null;
|
|
20
|
-
RemoteMessage remoteMessage = intent.getParcelableExtra("message");
|
|
21
|
-
|
|
22
|
-
return new HeadlessJsTaskConfig(
|
|
23
|
-
TASK_KEY,
|
|
24
|
-
ReactNativeFirebaseMessagingSerializer.remoteMessageToWritableMap(remoteMessage),
|
|
25
|
-
ReactNativeFirebaseJSON.getSharedInstance().getLongValue(TIMEOUT_JSON_KEY, TIMEOUT_DEFAULT),
|
|
26
|
-
// Prevents race condition where the user opens the app at the same time as a notification
|
|
27
|
-
// is delivered, causing a crash.
|
|
28
|
-
true);
|
|
29
|
-
}
|
|
30
|
-
}
|