infobip-mobile-messaging-react-native-plugin 14.9.0 → 14.10.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/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +2 -6
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingService.kt +18 -1
- package/android/src/newarchitecture/java/org/infobip/reactlibrary/mobilemessaging/MobileMessagingModule.kt +6 -0
- package/android/src/oldarchitecture/java/org/infobip/reactlibrary/mobilemessaging/MobileMessagingModule.kt +7 -0
- package/infobip-mobile-messaging-react-native-plugin-14.9.1.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +1 -1
- package/ios/MobileMessagingPlugin/RNMobileMessaging.swift +23 -6
- package/ios/MobileMessagingPlugin/RNMobileMessagingBridge.m +3 -0
- package/ios/MobileMessagingPlugin/RNMobileMessagingConfiguration.swift +1 -0
- package/package.json +1 -1
- package/src/index.d.ts +11 -0
- package/src/index.js +13 -0
- package/src/specs/NativeMobileMessaging.ts +3 -0
- package/infobip-mobile-messaging-react-native-plugin-14.8.3.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -66,7 +66,7 @@ repositories {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
dependencies {
|
|
69
|
-
def mmVersion = '
|
|
69
|
+
def mmVersion = '15.0.0'
|
|
70
70
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.20"
|
|
71
71
|
compileOnly "com.facebook.react:react-android"
|
|
72
72
|
implementation "androidx.annotation:annotation:1.9.1"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
xmlns:tools="http://schemas.android.com/tools">
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
2
|
|
|
4
3
|
<!-- Mobile Messaging permissions -->
|
|
5
4
|
|
|
@@ -20,10 +19,7 @@
|
|
|
20
19
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
21
20
|
<!-- Infobip rtc ui permissions -->
|
|
22
21
|
|
|
23
|
-
<application
|
|
24
|
-
tools:replace="android:usesCleartextTraffic"
|
|
25
|
-
android:usesCleartextTraffic="true"
|
|
26
|
-
>
|
|
22
|
+
<application>
|
|
27
23
|
<!-- Mobile Messaging components -->
|
|
28
24
|
<service
|
|
29
25
|
android:name="org.infobip.mobile.messaging.platform.MobileMessagingJobService"
|
|
@@ -417,6 +417,7 @@ class ReactNativeMobileMessagingService(
|
|
|
417
417
|
ctx.userAttributes,
|
|
418
418
|
ctx.forceDepersonalize,
|
|
419
419
|
ctx.keepAsLead,
|
|
420
|
+
ctx.setDeviceAsPrimary,
|
|
420
421
|
object : MobileMessaging.ResultListener<User>() {
|
|
421
422
|
override fun onResult(result: Result<User, MobileMessagingError>) {
|
|
422
423
|
if (result.isSuccess()) {
|
|
@@ -448,6 +449,7 @@ class ReactNativeMobileMessagingService(
|
|
|
448
449
|
mobileMessaging.depersonalize(object : MobileMessaging.ResultListener<SuccessPending>() {
|
|
449
450
|
override fun onResult(result: Result<SuccessPending, MobileMessagingError>) {
|
|
450
451
|
if (result.isSuccess) {
|
|
452
|
+
mobileMessaging.setJwtSupplier { null }
|
|
451
453
|
val state = when (result.data) {
|
|
452
454
|
SuccessPending.Pending -> "pending"
|
|
453
455
|
SuccessPending.Success -> "success"
|
|
@@ -510,10 +512,25 @@ class ReactNativeMobileMessagingService(
|
|
|
510
512
|
successCallback.invoke(readableMap)
|
|
511
513
|
}
|
|
512
514
|
|
|
515
|
+
fun cleanup(successCallback: Callback, errorCallback: Callback) {
|
|
516
|
+
RNMMLogger.d(Utils.TAG, "Cleanup...")
|
|
517
|
+
try {
|
|
518
|
+
mobileMessaging.setJwtSupplier { null }
|
|
519
|
+
mobileMessaging.cleanup()
|
|
520
|
+
successCallback.invoke()
|
|
521
|
+
} catch (e: Exception) {
|
|
522
|
+
errorCallback.invoke(Utils.callbackError(e.message, null))
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
513
526
|
fun setUserDataJwt(jwt: String?, successCallback: Callback, errorCallback: Callback) {
|
|
514
527
|
RNMMLogger.d(Utils.TAG, "SetUserDataJwt...")
|
|
515
528
|
try {
|
|
516
|
-
|
|
529
|
+
if (jwt.isNullOrEmpty()) {
|
|
530
|
+
mobileMessaging.setJwtSupplier(null)
|
|
531
|
+
} else {
|
|
532
|
+
mobileMessaging.setJwtSupplier { jwt }
|
|
533
|
+
}
|
|
517
534
|
successCallback.invoke()
|
|
518
535
|
} catch (e: Exception) {
|
|
519
536
|
errorCallback.invoke(Utils.callbackError(e.message, null))
|
|
@@ -160,6 +160,12 @@ class MobileMessagingModule(reactContext: ReactApplicationContext) : NativeMobil
|
|
|
160
160
|
service.showDialogForError(errorCode, successCallback, errorCallback)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// Cleanup
|
|
164
|
+
override fun cleanup(successCallback: Callback, errorCallback: Callback) {
|
|
165
|
+
RNMMLogger.d(TAG, "Cleanup...")
|
|
166
|
+
service.cleanup(successCallback, errorCallback)
|
|
167
|
+
}
|
|
168
|
+
|
|
163
169
|
// JWT
|
|
164
170
|
override fun setUserDataJwt(jwt: String?, successCallback: Callback, errorCallback: Callback) {
|
|
165
171
|
RNMMLogger.d(TAG, "SetUserDataJwt...")
|
|
@@ -187,6 +187,13 @@ class MobileMessagingModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
187
187
|
service.submitEventImmediately(eventData, successCallback, errorCallback)
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// Cleanup
|
|
191
|
+
@ReactMethod
|
|
192
|
+
fun cleanup(successCallback: Callback, errorCallback: Callback) {
|
|
193
|
+
RNMMLogger.d(TAG, "Cleanup...")
|
|
194
|
+
service.cleanup(successCallback, errorCallback)
|
|
195
|
+
}
|
|
196
|
+
|
|
190
197
|
// JWT
|
|
191
198
|
@ReactMethod
|
|
192
199
|
fun setUserDataJwt(jwt: String?, successCallback: Callback, errorCallback: Callback) {
|
|
Binary file
|
|
@@ -384,7 +384,8 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
384
384
|
let ua = uaDict == nil ? nil : MMUserAttributes(dictRepresentation: uaDict!)
|
|
385
385
|
let keepAsLead = (context["keepAsLead"] as? Bool) ?? false
|
|
386
386
|
let forceDepersonalize = context["forceDepersonalize"] as? Bool ?? false
|
|
387
|
-
|
|
387
|
+
let setDeviceAsPrimary = (context["setDeviceAsPrimary"] as? Bool) ?? false
|
|
388
|
+
MobileMessaging.personalize(forceDepersonalize: forceDepersonalize, keepAsLead: keepAsLead, setDeviceAsPrimary: setDeviceAsPrimary, userIdentity: ui, userAttributes: ua) { (error) in
|
|
388
389
|
if let error = error {
|
|
389
390
|
onError([error.reactNativeObject])
|
|
390
391
|
} else {
|
|
@@ -396,12 +397,15 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
396
397
|
@objc(depersonalize:onError:)
|
|
397
398
|
func depersonalize(onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
398
399
|
MobileMessaging.depersonalize(completion: { (status, error) in
|
|
399
|
-
if
|
|
400
|
-
onSuccess(["pending"])
|
|
401
|
-
} else if let error = error {
|
|
400
|
+
if let error = error {
|
|
402
401
|
onError([error.reactNativeObject])
|
|
403
402
|
} else {
|
|
404
|
-
|
|
403
|
+
MobileMessaging.jwtSupplier = nil
|
|
404
|
+
if (status == MMSuccessPending.pending) {
|
|
405
|
+
onSuccess(["pending"])
|
|
406
|
+
} else {
|
|
407
|
+
onSuccess(["success"])
|
|
408
|
+
}
|
|
405
409
|
}
|
|
406
410
|
})
|
|
407
411
|
}
|
|
@@ -528,9 +532,22 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
528
532
|
onError([NSError(type: .NotSupported).reactNativeObject])
|
|
529
533
|
}
|
|
530
534
|
|
|
535
|
+
@objc(cleanup:onError:)
|
|
536
|
+
func cleanup(onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
537
|
+
MobileMessaging.jwtSupplier = nil
|
|
538
|
+
RNMobileMessagingConfiguration.saveConfigToDefaults(rawConfig: [:])
|
|
539
|
+
MobileMessaging.cleanUpAndStop(false, completion: {
|
|
540
|
+
onSuccess([])
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
|
|
531
544
|
@objc(setUserDataJwt:onSuccess:onError:)
|
|
532
545
|
func setUserDataJwt(jwt: String?, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
533
|
-
|
|
546
|
+
if let jwt = jwt, !jwt.isEmpty {
|
|
547
|
+
MobileMessaging.jwtSupplier = VariableJwtSupplier(jwt: jwt)
|
|
548
|
+
} else {
|
|
549
|
+
MobileMessaging.jwtSupplier = nil
|
|
550
|
+
}
|
|
534
551
|
onSuccess(nil)
|
|
535
552
|
}
|
|
536
553
|
|
|
@@ -54,6 +54,9 @@ RCT_EXTERN_METHOD(fetchInboxMessages:(NSString *)token externalUserId:(NSString
|
|
|
54
54
|
RCT_EXTERN_METHOD(fetchInboxMessagesWithoutToken:(NSString *)externalUserId inboxFilterOptions:(NSDictionary *)inboxFilterOptions onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
55
55
|
RCT_EXTERN_METHOD(setInboxMessagesSeen:(NSString *)externalUserId messages:(NSArray *)messages onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
56
56
|
|
|
57
|
+
/*Cleanup*/
|
|
58
|
+
RCT_EXTERN_METHOD(cleanup:(RCTResponseSenderBlock)onSuccess onError:(RCTResponseSenderBlock)onError)
|
|
59
|
+
|
|
57
60
|
/*JWT*/
|
|
58
61
|
RCT_EXTERN_METHOD(setUserDataJwt:(NSString *)jwt onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
59
62
|
@end
|
|
@@ -154,6 +154,7 @@ class RNMobileMessagingConfiguration {
|
|
|
154
154
|
private static func serializedConfig(from rawConfig: [String: AnyObject]) -> [String: AnyObject] {
|
|
155
155
|
var rawConfig = rawConfig
|
|
156
156
|
rawConfig.removeValue(forKey: RNMobileMessagingConfiguration.Keys.applicationCode)
|
|
157
|
+
rawConfig.removeValue(forKey: RNMobileMessagingConfiguration.Keys.userDataJwt)
|
|
157
158
|
sanitizePrivacySettings(in: &rawConfig)
|
|
158
159
|
|
|
159
160
|
var serializableConfig = rawConfig.compactMapValues { value -> AnyObject? in
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infobip-mobile-messaging-react-native-plugin",
|
|
3
3
|
"title": "Infobip Mobile Messaging React Native Plugin",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.10.0",
|
|
5
5
|
"description": "Infobip Mobile Messaging React Native Plugin",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"scripts": {
|
package/src/index.d.ts
CHANGED
|
@@ -147,6 +147,7 @@ declare namespace MobileMessagingReactNative {
|
|
|
147
147
|
userAttributes?: Record<string, string | number | boolean | object[]>;
|
|
148
148
|
forceDepersonalize?: boolean;
|
|
149
149
|
keepAsLead?: boolean;
|
|
150
|
+
setDeviceAsPrimary?: boolean;
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
export interface Message {
|
|
@@ -723,6 +724,16 @@ declare namespace MobileMessagingReactNative {
|
|
|
723
724
|
*/
|
|
724
725
|
setChatDomain(domain?: string): void;
|
|
725
726
|
|
|
727
|
+
/**
|
|
728
|
+
* Cleans up the SDK, removing all data and stopping all services.
|
|
729
|
+
* After cleanup, you should call init() again with a new configuration to restart the SDK.
|
|
730
|
+
* JWT supplier is also cleared during cleanup.
|
|
731
|
+
*
|
|
732
|
+
* @param onSuccess will be called on success
|
|
733
|
+
* @param onError will be called on error
|
|
734
|
+
*/
|
|
735
|
+
cleanup(onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
736
|
+
|
|
726
737
|
/**
|
|
727
738
|
* Set JSON Web Token for user data operations and personalization.
|
|
728
739
|
* @param jwt JWT token in predefined format
|
package/src/index.js
CHANGED
|
@@ -886,6 +886,19 @@ class MobileMessaging {
|
|
|
886
886
|
RNMMChat.setChatDomain(domain);
|
|
887
887
|
}
|
|
888
888
|
|
|
889
|
+
/**
|
|
890
|
+
* Cleans up the SDK, removing all data and stopping all services.
|
|
891
|
+
* After cleanup, you should call init() again with a new configuration to restart the SDK.
|
|
892
|
+
* JWT supplier is also cleared during cleanup.
|
|
893
|
+
*
|
|
894
|
+
* @name cleanup
|
|
895
|
+
* @param {Function} onSuccess will be called on success
|
|
896
|
+
* @param {Function} onError will be called on error
|
|
897
|
+
*/
|
|
898
|
+
cleanup(onSuccess = function() {}, onError = function() {}) {
|
|
899
|
+
ReactNativeMobileMessaging.cleanup(onSuccess, onError);
|
|
900
|
+
}
|
|
901
|
+
|
|
889
902
|
/**
|
|
890
903
|
* Set JSON Web Token for user data operations and personalization.
|
|
891
904
|
* @param {String} jwt JWT token in predefined format
|
|
@@ -52,6 +52,9 @@ export interface Spec extends TurboModule {
|
|
|
52
52
|
submitEvent(eventData: Object, onError: (error: Object) => void): void;
|
|
53
53
|
submitEventImmediately(eventData: Object, onSuccess: () => void, onError: (error: Object) => void): void;
|
|
54
54
|
|
|
55
|
+
// Cleanup
|
|
56
|
+
cleanup(onSuccess: () => void, onError: (error: Object) => void): void;
|
|
57
|
+
|
|
55
58
|
// JWT
|
|
56
59
|
setUserDataJwt(jwt: string, onSuccess: () => void, onError: (error: Object) => void): void;
|
|
57
60
|
|
|
Binary file
|