react-native-mapp-plugin 1.0.4-beta3 → 1.0.4-beta7
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/.idea/React-native-plugin.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/{android/.idea → .idea}/vcs.xml +5 -5
- package/.idea/workspace.xml +85 -0
- package/.vscode/settings.json +2 -2
- package/CustomEvent.js +47 -47
- package/Mapp.js +414 -414
- package/MappEventEmitter.js +41 -41
- package/README.md +93 -93
- package/RNMappPlugin.podspec +29 -29
- package/__package.json +37 -37
- package/android/.classpath +6 -6
- package/android/.project +34 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -13
- package/android/build.gradle +75 -75
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -7
- package/android/gradle.properties +15 -15
- package/android/src/main/AndroidManifest.xml +65 -65
- package/android/src/main/java/com/reactlibrary/ActivityListener.java +43 -43
- package/android/src/main/java/com/reactlibrary/Event.java +28 -28
- package/android/src/main/java/com/reactlibrary/EventEmitter.java +153 -153
- package/android/src/main/java/com/reactlibrary/HelperActivity.java +254 -254
- package/android/src/main/java/com/reactlibrary/IntentNotificationEvent.java +54 -54
- package/android/src/main/java/com/reactlibrary/MessageService.java +21 -21
- package/android/src/main/java/com/reactlibrary/MyPushBroadcastReceiver.java +43 -43
- package/android/src/main/java/com/reactlibrary/PushNotificationEvent.java +37 -37
- package/android/src/main/java/com/reactlibrary/RNMappPluginModule.java +601 -601
- package/android/src/main/java/com/reactlibrary/RNMappPluginPackage.java +34 -34
- package/android/src/main/java/com/reactlibrary/RNUtils.java +191 -191
- package/android/src/main/java/com/reactlibrary/RequestPermissionsTask.java +58 -58
- package/android/src/main/res/values/styles.xml +14 -14
- package/index.js +8 -8
- package/ios/Frameworks/AppoxeeInapp.framework/Versions/A/Headers/APXInBoxMessage.h +101 -101
- package/ios/Frameworks/AppoxeeInapp.framework/Versions/A/Headers/AppoxeeInapp.h +153 -153
- package/ios/Frameworks/AppoxeeInapp.framework/Versions/A/Headers/AppoxeeInappSDK.h +9 -9
- package/ios/Frameworks/AppoxeeLocationServices.framework/Versions/A/Headers/AppoxeeLocationManager.h +122 -122
- package/ios/Frameworks/AppoxeeLocationServices.framework/Versions/A/Headers/AppoxeeLocationServices.h +10 -10
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXClientDevice.h +26 -26
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXInterfaceService.h +49 -49
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXPushNotification.h +92 -92
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXPushNotificationAction.h +20 -20
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXPushNotificationActionButton.h +19 -19
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXPushNotificationActionButtonAction.h +34 -34
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/APXRichMessage.h +58 -58
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/Appoxee.h +840 -840
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/AppoxeeManager.h +385 -385
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/A/Headers/AppoxeeSDK.h +12 -12
- package/ios/Frameworks/AppoxeeSDKResources.bundle/app_conf.json +340 -340
- package/ios/RNMappEventEmmiter.h +25 -25
- package/ios/RNMappEventEmmiter.m +221 -221
- package/ios/RNMappPluginModule.h +10 -10
- package/ios/RNMappPluginModule.m +311 -311
- package/iospatch.sh +13 -13
- package/jsdoc.conf.json +14 -14
- package/package.json +49 -36
- package/android/.gradle/5.6.4/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/5.6.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.6.4/fileContent/fileContent.lock +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.4/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/5.6.4/gc.properties +0 -0
- package/android/.gradle/5.6.4/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/5.6.4/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/5.6.4/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/5.6.4/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/7.0-rc-1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.0-rc-1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.0-rc-1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.0-rc-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.0-rc-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.0-rc-1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -21
- package/android/.idea/jarRepositories.xml +0 -35
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_core_core_1_3_1_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_v13_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_media_media_1_0_1_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +0 -19
- package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_base_17_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_basement_17_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_location_16_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_places_placereport_16_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_stats_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_auto_value_auto_value_annotations_1_6_5.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_dagger_dagger_2_24.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_common_19_0_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_iid_20_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_iid_interop_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_measurement_connector_18_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_messaging_20_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_mapp_sdk_mapp_android_6_0_17_special7_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0.xml +0 -13
- package/android/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +0 -13
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -13
- package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +0 -11
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -122
- package/android/.idea/modules/app/android.app.iml +0 -26
- package/android/.idea/modules.xml +0 -9
- package/android/build/generated/source/buildConfig/debug/com/reactlibrary/BuildConfig.java +0 -18
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -70
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
- package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -2993
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/packageDebugResources/merged.dir/values/values.xml +0 -13
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -11
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/ActivityListener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/Event.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/EventEmitter$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/EventEmitter$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/EventEmitter$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/EventEmitter.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/HelperActivity$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/HelperActivity$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/HelperActivity$ActivityResult.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/HelperActivity.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/IntentNotificationEvent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/MessageService.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/MyPushBroadcastReceiver.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/PushNotificationEvent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginModule$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginModule$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNMappPluginPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNUtils$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RNUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RequestPermissionsTask$Callback.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/RequestPermissionsTask.class +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -70
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -3
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -134
- package/android/build/intermediates/merged_java_res/debug/out.jar +0 -0
- package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
- package/android/build/intermediates/packaged_res/debug/values/values.xml +0 -13
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1856
- package/android/build/outputs/aar/android-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -135
- package/android/local.properties +0 -8
- package/ios/Frameworks/AppoxeeInapp.framework/AppoxeeInapp +0 -1
- package/ios/Frameworks/AppoxeeInapp.framework/Headers +0 -1
- package/ios/Frameworks/AppoxeeInapp.framework/Versions/Current +0 -1
- package/ios/Frameworks/AppoxeeLocationServices.framework/AppoxeeLocationServices +0 -1
- package/ios/Frameworks/AppoxeeLocationServices.framework/Headers +0 -1
- package/ios/Frameworks/AppoxeeLocationServices.framework/Versions/Current +0 -1
- package/ios/Frameworks/AppoxeeSDK.framework/AppoxeeSDK +0 -1
- package/ios/Frameworks/AppoxeeSDK.framework/Headers +0 -1
- package/ios/Frameworks/AppoxeeSDK.framework/Versions/Current +0 -1
|
@@ -1,602 +1,602 @@
|
|
|
1
|
-
|
|
2
|
-
package com.reactlibrary;
|
|
3
|
-
|
|
4
|
-
import android.Manifest;
|
|
5
|
-
import android.app.Application;
|
|
6
|
-
import android.content.pm.ActivityInfo;
|
|
7
|
-
import android.content.pm.PackageManager;
|
|
8
|
-
import android.os.Build;
|
|
9
|
-
import android.util.Log;
|
|
10
|
-
|
|
11
|
-
import androidx.core.app.NotificationManagerCompat;
|
|
12
|
-
import androidx.core.content.ContextCompat;
|
|
13
|
-
|
|
14
|
-
import com.appoxee.Appoxee;
|
|
15
|
-
import com.appoxee.AppoxeeOptions;
|
|
16
|
-
import com.appoxee.DeviceInfo;
|
|
17
|
-
import com.appoxee.internal.inapp.model.APXInboxMessage;
|
|
18
|
-
import com.appoxee.internal.inapp.model.ApxInAppExtras;
|
|
19
|
-
import com.appoxee.internal.inapp.model.InAppInboxCallback;
|
|
20
|
-
import com.appoxee.internal.inapp.model.InAppStatistics;
|
|
21
|
-
import com.appoxee.internal.inapp.model.MessageContext;
|
|
22
|
-
import com.appoxee.internal.inapp.model.Tracking;
|
|
23
|
-
import com.appoxee.internal.inapp.model.TrackingAttributes;
|
|
24
|
-
import com.appoxee.internal.service.AppoxeeServiceAdapter;
|
|
25
|
-
import com.appoxee.push.NotificationMode;
|
|
26
|
-
import com.appoxee.push.PushData;
|
|
27
|
-
import com.facebook.react.bridge.Arguments;
|
|
28
|
-
import com.facebook.react.bridge.Callback;
|
|
29
|
-
import com.facebook.react.bridge.LifecycleEventListener;
|
|
30
|
-
import com.facebook.react.bridge.Promise;
|
|
31
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
32
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
33
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
34
|
-
import com.facebook.react.bridge.WritableArray;
|
|
35
|
-
import com.facebook.react.bridge.WritableMap;
|
|
36
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
37
|
-
import com.google.firebase.messaging.RemoteMessage;
|
|
38
|
-
|
|
39
|
-
import org.json.JSONException;
|
|
40
|
-
import org.json.JSONObject;
|
|
41
|
-
|
|
42
|
-
import java.util.Iterator;
|
|
43
|
-
import java.util.List;
|
|
44
|
-
import java.util.Map;
|
|
45
|
-
import java.util.Objects;
|
|
46
|
-
import java.util.concurrent.ConcurrentHashMap;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Created by Aleksandar Marinkovic on 2019-05-15.
|
|
50
|
-
* Copyright (c) 2019 MAPP.
|
|
51
|
-
*/
|
|
52
|
-
@SuppressWarnings("ALL")
|
|
53
|
-
public class RNMappPluginModule extends ReactContextBaseJavaModule {
|
|
54
|
-
|
|
55
|
-
private final ReactApplicationContext reactContext;
|
|
56
|
-
private Map<Callback, String> mFeedSubscriberMap = new ConcurrentHashMap<>();
|
|
57
|
-
private Map<Callback, Boolean> mCallbackWasCalledMap = new ConcurrentHashMap<>();
|
|
58
|
-
private Application application = null;
|
|
59
|
-
|
|
60
|
-
public RNMappPluginModule(ReactApplicationContext reactContext) {
|
|
61
|
-
super(reactContext);
|
|
62
|
-
this.reactContext = reactContext;
|
|
63
|
-
application = (Application) reactContext.getApplicationContext();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@Override
|
|
67
|
-
public String getName() {
|
|
68
|
-
return "RNMappPluginModule";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Override
|
|
72
|
-
public void initialize() {
|
|
73
|
-
super.initialize();
|
|
74
|
-
// application is initialized in constructor
|
|
75
|
-
/* if (getCurrentActivity() != null)
|
|
76
|
-
application = (Application) getCurrentActivity().getApplication();*/
|
|
77
|
-
getReactApplicationContext().addLifecycleEventListener(new LifecycleEventListener() {
|
|
78
|
-
@Override
|
|
79
|
-
public void onHostResume() {
|
|
80
|
-
Appoxee.engage(application);
|
|
81
|
-
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Override
|
|
86
|
-
public void onHostPause() {
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@Override
|
|
91
|
-
public void onHostDestroy() {
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
EventEmitter.shared().attachReactContext(getReactApplicationContext());
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private void reportResultWithCallback(Callback callback, String error, Object result) {
|
|
101
|
-
if (callback != null) {
|
|
102
|
-
if (error != null) {
|
|
103
|
-
callback.invoke(error);
|
|
104
|
-
} else {
|
|
105
|
-
callback.invoke(null, result);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@ReactMethod
|
|
111
|
-
public void setRemoteMessage(String msgJson) {
|
|
112
|
-
RemoteMessage remoteMessage = getRemoteMessage(msgJson);
|
|
113
|
-
if (remoteMessage != null){
|
|
114
|
-
Appoxee.instance().setRemoteMessage(remoteMessage);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@ReactMethod
|
|
119
|
-
public void isPushFromMapp(String msgJson, Promise promise) {
|
|
120
|
-
try {
|
|
121
|
-
JSONObject json = new JSONObject(msgJson);
|
|
122
|
-
boolean mappPush = json.has("data") && json.getJSONObject("data").has("p");
|
|
123
|
-
promise.resolve(mappPush);
|
|
124
|
-
} catch (Exception e) {
|
|
125
|
-
promise.resolve(false);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@ReactMethod
|
|
130
|
-
public void setToken(String token) {
|
|
131
|
-
Appoxee.instance().setToken(token);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@ReactMethod
|
|
135
|
-
public void setAlias(String alias) {
|
|
136
|
-
Appoxee.instance().setAlias(alias);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
@ReactMethod
|
|
140
|
-
public void engage2() {
|
|
141
|
-
Appoxee.engage(Objects.requireNonNull(application));
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@ReactMethod
|
|
146
|
-
public void engage(String sdkKey, String googleProjectId, String server, String appID, String tenantID) {
|
|
147
|
-
AppoxeeOptions opt = new AppoxeeOptions();
|
|
148
|
-
opt.appID = appID;
|
|
149
|
-
opt.sdkKey = sdkKey;
|
|
150
|
-
opt.googleProjectId = googleProjectId;
|
|
151
|
-
opt.server = AppoxeeOptions.Server.valueOf(server);
|
|
152
|
-
if (server.equals("TEST") || server.equals("TEST55") || server.equals("TEST_55")) {
|
|
153
|
-
opt.cepURL = "https://jamie-test.shortest-route.com";
|
|
154
|
-
}
|
|
155
|
-
opt.notificationMode = NotificationMode.BACKGROUND_AND_FOREGROUND;
|
|
156
|
-
opt.tenantID = tenantID;
|
|
157
|
-
Appoxee.engage(Objects.requireNonNull(application), opt);
|
|
158
|
-
Appoxee.instance().addInitListener(new Appoxee.OnInitCompletedListener() {
|
|
159
|
-
@Override
|
|
160
|
-
public void onInitCompleted(boolean successful, Exception failReason) {
|
|
161
|
-
/**
|
|
162
|
-
* OnInitCompleteListener must be attached;
|
|
163
|
-
* Internally {@link AppoxeeServiceAdapter#getDeviceInfoDMC()} is called and "user_id" created.
|
|
164
|
-
* If "user_id" is null InApp messages are not working.
|
|
165
|
-
*/
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@ReactMethod
|
|
173
|
-
public void engageTestServer(String cepURl, String sdkKey, String googleProjectId, String server, String appID, String tenantID) {
|
|
174
|
-
AppoxeeOptions opt = new AppoxeeOptions();
|
|
175
|
-
opt.appID = appID;
|
|
176
|
-
opt.sdkKey = sdkKey;
|
|
177
|
-
opt.googleProjectId = googleProjectId;
|
|
178
|
-
opt.server = AppoxeeOptions.Server.valueOf(server);
|
|
179
|
-
opt.cepURL = cepURl;
|
|
180
|
-
opt.tenantID = tenantID;
|
|
181
|
-
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
182
|
-
|
|
183
|
-
Appoxee.engage(Objects.requireNonNull(application), opt);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
@ReactMethod
|
|
187
|
-
public void setPushEnabled(boolean optIn) {
|
|
188
|
-
Appoxee.instance().setPushEnabled(optIn);
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@ReactMethod
|
|
193
|
-
public void isPushEnabled(Promise promise) {
|
|
194
|
-
promise.resolve(Appoxee.instance().isPushEnabled());
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
@ReactMethod
|
|
199
|
-
public void isReady(Promise promise) {
|
|
200
|
-
promise.resolve(Appoxee.instance().isReady());
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@ReactMethod
|
|
205
|
-
public void onInitCompletedListener(final Promise promise) {
|
|
206
|
-
Appoxee.instance().addInitListener(new Appoxee.OnInitCompletedListener() {
|
|
207
|
-
@Override
|
|
208
|
-
public void onInitCompleted(boolean b, Exception e) {
|
|
209
|
-
promise.resolve(b);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
@ReactMethod
|
|
216
|
-
public void setAttribute(String key, String value) {
|
|
217
|
-
Appoxee.instance().setAttribute(key, value);
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
@ReactMethod
|
|
222
|
-
public void setAttributeBoolean(String key, Boolean value) {
|
|
223
|
-
Appoxee.instance().setAttribute(key, value);
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
@ReactMethod
|
|
228
|
-
public void setAttributeInt(String key, Integer value) {
|
|
229
|
-
Appoxee.instance().setAttribute(key, value);
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
@ReactMethod
|
|
234
|
-
public void addTag(String tag) {
|
|
235
|
-
Appoxee.instance().addTag(tag);
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@ReactMethod
|
|
240
|
-
public void removeTag(String tag) {
|
|
241
|
-
Appoxee.instance().removeTag(tag);
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@ReactMethod
|
|
246
|
-
public void getTags(Promise promise) {
|
|
247
|
-
|
|
248
|
-
WritableArray array = Arguments.createArray();
|
|
249
|
-
for (String tag : Appoxee.instance().getTags()) {
|
|
250
|
-
array.pushString(tag);
|
|
251
|
-
}
|
|
252
|
-
promise.resolve(array);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
@ReactMethod
|
|
256
|
-
public void removeAttribute(String attribute) {
|
|
257
|
-
Appoxee.instance().removeAttribute(attribute);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
@ReactMethod
|
|
262
|
-
public void getAlias(Promise promise) {
|
|
263
|
-
promise.resolve(Appoxee.instance().getAlias());
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
@ReactMethod
|
|
267
|
-
public void getDeviceInfo(Promise promise) {
|
|
268
|
-
promise.resolve(getDeviceInfoJson(Appoxee.instance().getDeviceInfo()));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
@ReactMethod
|
|
272
|
-
public void getAttributeStringValue(String value, Promise promise) {
|
|
273
|
-
promise.resolve(Appoxee.instance().getAttributeStringValue(value));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
@ReactMethod
|
|
278
|
-
public void lockScreenOrientation(Integer orientation) {
|
|
279
|
-
Appoxee.setOrientation(Objects.requireNonNull((Application) reactContext.getApplicationContext()), orientation);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@ReactMethod
|
|
283
|
-
public void removeBadgeNumber() {
|
|
284
|
-
Appoxee.removeBadgeNumber(Objects.requireNonNull((Application) reactContext.getApplicationContext()));
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
@ReactMethod
|
|
288
|
-
public void startGeoFencing() {
|
|
289
|
-
|
|
290
|
-
Appoxee.instance().startGeoFencing();
|
|
291
|
-
// if (Build.VERSION.SDK_INT < 23) {
|
|
292
|
-
// Appoxee.instance().startGeoFencing();
|
|
293
|
-
// } else if (Build.VERSION.SDK_INT <= 28) {
|
|
294
|
-
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
295
|
-
// new RequestPermissionsTask.Callback() {
|
|
296
|
-
// @Override
|
|
297
|
-
// public void onResult(boolean enabled) {
|
|
298
|
-
// if (enabled) {
|
|
299
|
-
//
|
|
300
|
-
// Appoxee.instance().startGeoFencing();
|
|
301
|
-
// }
|
|
302
|
-
// }
|
|
303
|
-
// });
|
|
304
|
-
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
305
|
-
//
|
|
306
|
-
// } else if (Build.VERSION.SDK_INT == 29) {
|
|
307
|
-
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
308
|
-
// new RequestPermissionsTask.Callback() {
|
|
309
|
-
// @Override
|
|
310
|
-
// public void onResult(boolean enabled) {
|
|
311
|
-
// if (enabled) {
|
|
312
|
-
//
|
|
313
|
-
// Appoxee.instance().startGeoFencing();
|
|
314
|
-
// }
|
|
315
|
-
// }
|
|
316
|
-
// });
|
|
317
|
-
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
|
318
|
-
//
|
|
319
|
-
// } else if (Build.VERSION.SDK_INT == 30) {
|
|
320
|
-
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
321
|
-
// new RequestPermissionsTask.Callback() {
|
|
322
|
-
// @Override
|
|
323
|
-
// public void onResult(boolean enabled) {
|
|
324
|
-
// if (enabled) {
|
|
325
|
-
// Appoxee.instance().startGeoFencing();
|
|
326
|
-
// RequestPermissionsTask task2 = new RequestPermissionsTask(getReactApplicationContext(),
|
|
327
|
-
// new RequestPermissionsTask.Callback() {
|
|
328
|
-
// @Override
|
|
329
|
-
// public void onResult(boolean enabled) {
|
|
330
|
-
// if (enabled) {
|
|
331
|
-
// Appoxee.instance().startGeoFencing();
|
|
332
|
-
// }
|
|
333
|
-
// }
|
|
334
|
-
// });
|
|
335
|
-
// task2.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
|
336
|
-
//
|
|
337
|
-
// }
|
|
338
|
-
// }
|
|
339
|
-
// });
|
|
340
|
-
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
341
|
-
// }
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
@ReactMethod
|
|
346
|
-
public void stopGeoFencing() {
|
|
347
|
-
Appoxee.instance().stopGeoFencing();
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
@ReactMethod
|
|
351
|
-
public void fetchInboxMessage(final Promise promise) {
|
|
352
|
-
|
|
353
|
-
Appoxee.instance().fetchInboxMessages(reactContext.getApplicationContext());
|
|
354
|
-
|
|
355
|
-
InAppInboxCallback inAppInboxCallback = new InAppInboxCallback();
|
|
356
|
-
inAppInboxCallback.addInAppInboxMessagesReceivedCallback(new InAppInboxCallback.onInAppInboxMessagesReceived() {
|
|
357
|
-
@Override
|
|
358
|
-
public void onInAppInboxMessages(List<APXInboxMessage> richMessages) {
|
|
359
|
-
WritableArray messagesArray = Arguments.createArray();
|
|
360
|
-
if (richMessages != null)
|
|
361
|
-
for (APXInboxMessage message : richMessages) {
|
|
362
|
-
messagesArray.pushMap(messageToJson(message));
|
|
363
|
-
}
|
|
364
|
-
promise.resolve(messagesArray);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
@Override
|
|
368
|
-
public void onInAppInboxMessage(final APXInboxMessage message) {
|
|
369
|
-
promise.resolve(messageToJson(message));
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
@ReactMethod
|
|
377
|
-
public void triggerInApp(String key) {
|
|
378
|
-
Appoxee.instance().triggerInApp((getCurrentActivity()), key);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
@ReactMethod
|
|
382
|
-
public void inAppMarkAsRead(Integer templateId, String eventId) {
|
|
383
|
-
Appoxee.instance().triggerStatistcs((getCurrentActivity()), getInAppStatisticsRequestObject(templateId,
|
|
384
|
-
eventId,
|
|
385
|
-
InAppStatistics.INBOX_INBOX_MESSAGE_READ_KEY, null, null, null));
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
@ReactMethod
|
|
389
|
-
public void inAppMarkAsUnRead(Integer templateId, String eventId) {
|
|
390
|
-
Appoxee.instance().triggerStatistcs((reactContext.getApplicationContext()), getInAppStatisticsRequestObject(templateId,
|
|
391
|
-
eventId,
|
|
392
|
-
InAppStatistics.INBOX_INBOX_MESSAGE_UNREAD_KEY, null, null, null));
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
@ReactMethod
|
|
396
|
-
public void inAppMarkAsDeleted(Integer templateId, String eventId) {
|
|
397
|
-
Appoxee.instance().triggerStatistcs((reactContext.getApplicationContext()), getInAppStatisticsRequestObject(templateId,
|
|
398
|
-
eventId,
|
|
399
|
-
InAppStatistics.INBOX_INBOX_MESSAGE_DELETED_KEY, null, null, null));
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
@ReactMethod
|
|
403
|
-
public void triggerStatistic(Integer templateId, String originalEventId,
|
|
404
|
-
String trackingKey, Long displayMillis,
|
|
405
|
-
String reason, String link) {
|
|
406
|
-
Appoxee.instance()
|
|
407
|
-
.triggerStatistcs((reactContext.getApplicationContext())
|
|
408
|
-
, getInAppStatisticsRequestObject(templateId, originalEventId, trackingKey, displayMillis, reason, link));
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
@ReactMethod
|
|
412
|
-
public void isDeviceRegistered(Promise promise) {
|
|
413
|
-
promise.resolve(Appoxee.instance().isDeviceRegistered());
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
@ReactMethod
|
|
419
|
-
public void addAndroidListener(String eventName) {
|
|
420
|
-
EventEmitter.shared().addAndroidListener(eventName);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
@ReactMethod
|
|
424
|
-
public void removeAndroidListeners(int count) {
|
|
425
|
-
EventEmitter.shared().removeAndroidListeners(count);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
private static InAppStatistics getInAppStatisticsRequestObject(int templateId, String originalEventId,
|
|
430
|
-
String trackingKey, Long displayMillis,
|
|
431
|
-
String reason, String link) {
|
|
432
|
-
|
|
433
|
-
InAppStatistics inAppStatistics = new InAppStatistics();
|
|
434
|
-
//This will be received from the respective Screens.
|
|
435
|
-
MessageContext mc = new MessageContext();
|
|
436
|
-
mc.setTemplateId(templateId);
|
|
437
|
-
mc.setOriginialEventid(originalEventId);
|
|
438
|
-
inAppStatistics.setMessageContext(mc);
|
|
439
|
-
Tracking tk = new Tracking();
|
|
440
|
-
tk.setTrackingKey(trackingKey);
|
|
441
|
-
TrackingAttributes ta = new TrackingAttributes();
|
|
442
|
-
ta.setTimeSinceDisplayMillis(displayMillis);
|
|
443
|
-
ta.setReason(reason);
|
|
444
|
-
ta.setLink(link);
|
|
445
|
-
tk.setTrackingAttributes(ta);
|
|
446
|
-
inAppStatistics.setTracking(tk);
|
|
447
|
-
|
|
448
|
-
return inAppStatistics;
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
private WritableMap messageToJson(APXInboxMessage msg) {
|
|
454
|
-
WritableMap msgJson = new WritableNativeMap();
|
|
455
|
-
|
|
456
|
-
try {
|
|
457
|
-
msgJson.putInt("templateId", msg.getTemplateId());
|
|
458
|
-
msgJson.putString("title", msg.getContent());
|
|
459
|
-
msgJson.putString("eventId", msg.getEventId());
|
|
460
|
-
if (msg.getExpirationDate() != null)
|
|
461
|
-
msgJson.putString("expirationDate", msg.getExpirationDate().toString());
|
|
462
|
-
if (msg.getIconUrl() != null)
|
|
463
|
-
msgJson.putString("iconURl", msg.getIconUrl());
|
|
464
|
-
if (msg.getStatus() != null)
|
|
465
|
-
msgJson.putString("status", msg.getStatus());
|
|
466
|
-
if (msg.getSubject() != null)
|
|
467
|
-
msgJson.putString("subject", msg.getSubject());
|
|
468
|
-
if (msg.getSummary() != null)
|
|
469
|
-
msgJson.putString("summary", msg.getSummary());
|
|
470
|
-
if (msg.getExtras() != null)
|
|
471
|
-
for (ApxInAppExtras apxInAppExtras : msg.getExtras())
|
|
472
|
-
msgJson.putString(apxInAppExtras.getName(), apxInAppExtras.getValue());
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
} catch (Exception e) {
|
|
476
|
-
e.printStackTrace();
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
return msgJson;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
private WritableMap getDeviceInfoJson(DeviceInfo deviceInfoList) {
|
|
484
|
-
WritableMap deviceInfo = new WritableNativeMap();
|
|
485
|
-
try {
|
|
486
|
-
deviceInfo.putString("id", deviceInfoList.id);
|
|
487
|
-
deviceInfo.putString("appVersion", deviceInfoList.appVersion);
|
|
488
|
-
deviceInfo.putString("sdkVersion", deviceInfoList.sdkVersion);
|
|
489
|
-
deviceInfo.putString("locale", deviceInfoList.locale);
|
|
490
|
-
deviceInfo.putString("timezone", deviceInfoList.timezone);
|
|
491
|
-
deviceInfo.putString("deviceModel", deviceInfoList.deviceModel);
|
|
492
|
-
deviceInfo.putString("manufacturer", deviceInfoList.manufacturer);
|
|
493
|
-
deviceInfo.putString("osVersion", deviceInfoList.osVersion);
|
|
494
|
-
deviceInfo.putString("resolution", deviceInfoList.resolution);
|
|
495
|
-
deviceInfo.putString("density", String.valueOf(deviceInfoList.density));
|
|
496
|
-
} catch (Exception e) {
|
|
497
|
-
e.printStackTrace();
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
return deviceInfo;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
public static WritableMap getPushMessageToJSon(PushData pushData) {
|
|
505
|
-
WritableMap deviceInfo = new WritableNativeMap();
|
|
506
|
-
try {
|
|
507
|
-
deviceInfo.putString("id", String.valueOf(pushData.id));
|
|
508
|
-
deviceInfo.putString("title", pushData.title);
|
|
509
|
-
deviceInfo.putString("bigText", pushData.bigText);
|
|
510
|
-
deviceInfo.putString("sound", pushData.sound);
|
|
511
|
-
if (pushData.actionUri != null)
|
|
512
|
-
deviceInfo.putString("actionUri", pushData.actionUri.toString());
|
|
513
|
-
deviceInfo.putString("collapseKey", pushData.collapseKey);
|
|
514
|
-
deviceInfo.putInt("badgeNumber", pushData.badgeNumber);
|
|
515
|
-
deviceInfo.putString("silentType", pushData.silentType);
|
|
516
|
-
deviceInfo.putString("silentData", pushData.silentData);
|
|
517
|
-
deviceInfo.putString("category", pushData.category);
|
|
518
|
-
if (pushData.extraFields != null)
|
|
519
|
-
for (Map.Entry<String, String> entry : pushData.extraFields.entrySet()) {
|
|
520
|
-
String key = entry.getKey();
|
|
521
|
-
String value = entry.getValue();
|
|
522
|
-
deviceInfo.putString(key, value);
|
|
523
|
-
}
|
|
524
|
-
} catch (Exception e) {
|
|
525
|
-
e.printStackTrace();
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
return deviceInfo;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
private RemoteMessage getRemoteMessage(String jsonMsg) {
|
|
532
|
-
if (jsonMsg == null)
|
|
533
|
-
return null;
|
|
534
|
-
|
|
535
|
-
final String KEY_TOKEN = "token";
|
|
536
|
-
final String KEY_COLLAPSE_KEY = "collapseKey";
|
|
537
|
-
final String KEY_DATA = "data";
|
|
538
|
-
final String KEY_FROM = "from";
|
|
539
|
-
final String KEY_MESSAGE_ID = "messageId";
|
|
540
|
-
final String KEY_MESSAGE_TYPE = "messageType";
|
|
541
|
-
final String KEY_SENT_TIME = "sentTime";
|
|
542
|
-
final String KEY_ERROR = "error";
|
|
543
|
-
final String KEY_TO = "to";
|
|
544
|
-
final String KEY_TTL = "ttl";
|
|
545
|
-
|
|
546
|
-
JSONObject json = null;
|
|
547
|
-
try {
|
|
548
|
-
json = new JSONObject(jsonMsg);
|
|
549
|
-
|
|
550
|
-
String collapseKey = json.has(KEY_COLLAPSE_KEY) ? json.getString(KEY_COLLAPSE_KEY) : "";
|
|
551
|
-
String messageId = json.has(KEY_MESSAGE_ID) ? json.getString(KEY_MESSAGE_ID) : "";
|
|
552
|
-
String messageType = json.has(KEY_MESSAGE_TYPE) ? json.getString(KEY_MESSAGE_TYPE) : "";
|
|
553
|
-
int ttl = json.has(KEY_TTL) ? json.getInt(KEY_TTL) : 0;
|
|
554
|
-
JSONObject data = json.has(KEY_DATA) ? json.getJSONObject(KEY_DATA) : null;
|
|
555
|
-
|
|
556
|
-
RemoteMessage.Builder builder = new RemoteMessage.Builder("appoxee@gcm.googleapis.com")
|
|
557
|
-
.setMessageType(messageType)
|
|
558
|
-
.setMessageId(messageId)
|
|
559
|
-
.setTtl(ttl)
|
|
560
|
-
.setCollapseKey(collapseKey);
|
|
561
|
-
|
|
562
|
-
if (data != null) {
|
|
563
|
-
for (Iterator<String> it = data.keys(); it.hasNext();) {
|
|
564
|
-
String k = it.next();
|
|
565
|
-
builder.addData(k, data.getString(k));
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return builder.build();
|
|
570
|
-
} catch (JSONException e) {
|
|
571
|
-
e.printStackTrace();
|
|
572
|
-
}
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
private boolean shouldRequestLocationPermissions() {
|
|
577
|
-
if (Build.VERSION.SDK_INT < 23) {
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return ContextCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED &&
|
|
582
|
-
ContextCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
@ReactMethod
|
|
586
|
-
public void clearNotifications() {
|
|
587
|
-
NotificationManagerCompat.from(reactContext.getApplicationContext()).cancelAll();
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
@ReactMethod
|
|
592
|
-
public void clearNotification(int id) {
|
|
593
|
-
NotificationManagerCompat.from(reactContext.getApplicationContext()).cancel(id);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
@ReactMethod
|
|
597
|
-
public void logOut(boolean pushEnabled) {
|
|
598
|
-
Appoxee.instance().logOut(application, pushEnabled);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
|
|
1
|
+
|
|
2
|
+
package com.reactlibrary;
|
|
3
|
+
|
|
4
|
+
import android.Manifest;
|
|
5
|
+
import android.app.Application;
|
|
6
|
+
import android.content.pm.ActivityInfo;
|
|
7
|
+
import android.content.pm.PackageManager;
|
|
8
|
+
import android.os.Build;
|
|
9
|
+
import android.util.Log;
|
|
10
|
+
|
|
11
|
+
import androidx.core.app.NotificationManagerCompat;
|
|
12
|
+
import androidx.core.content.ContextCompat;
|
|
13
|
+
|
|
14
|
+
import com.appoxee.Appoxee;
|
|
15
|
+
import com.appoxee.AppoxeeOptions;
|
|
16
|
+
import com.appoxee.DeviceInfo;
|
|
17
|
+
import com.appoxee.internal.inapp.model.APXInboxMessage;
|
|
18
|
+
import com.appoxee.internal.inapp.model.ApxInAppExtras;
|
|
19
|
+
import com.appoxee.internal.inapp.model.InAppInboxCallback;
|
|
20
|
+
import com.appoxee.internal.inapp.model.InAppStatistics;
|
|
21
|
+
import com.appoxee.internal.inapp.model.MessageContext;
|
|
22
|
+
import com.appoxee.internal.inapp.model.Tracking;
|
|
23
|
+
import com.appoxee.internal.inapp.model.TrackingAttributes;
|
|
24
|
+
import com.appoxee.internal.service.AppoxeeServiceAdapter;
|
|
25
|
+
import com.appoxee.push.NotificationMode;
|
|
26
|
+
import com.appoxee.push.PushData;
|
|
27
|
+
import com.facebook.react.bridge.Arguments;
|
|
28
|
+
import com.facebook.react.bridge.Callback;
|
|
29
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
30
|
+
import com.facebook.react.bridge.Promise;
|
|
31
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
32
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
33
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
34
|
+
import com.facebook.react.bridge.WritableArray;
|
|
35
|
+
import com.facebook.react.bridge.WritableMap;
|
|
36
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
37
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
38
|
+
|
|
39
|
+
import org.json.JSONException;
|
|
40
|
+
import org.json.JSONObject;
|
|
41
|
+
|
|
42
|
+
import java.util.Iterator;
|
|
43
|
+
import java.util.List;
|
|
44
|
+
import java.util.Map;
|
|
45
|
+
import java.util.Objects;
|
|
46
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Created by Aleksandar Marinkovic on 2019-05-15.
|
|
50
|
+
* Copyright (c) 2019 MAPP.
|
|
51
|
+
*/
|
|
52
|
+
@SuppressWarnings("ALL")
|
|
53
|
+
public class RNMappPluginModule extends ReactContextBaseJavaModule {
|
|
54
|
+
|
|
55
|
+
private final ReactApplicationContext reactContext;
|
|
56
|
+
private Map<Callback, String> mFeedSubscriberMap = new ConcurrentHashMap<>();
|
|
57
|
+
private Map<Callback, Boolean> mCallbackWasCalledMap = new ConcurrentHashMap<>();
|
|
58
|
+
private Application application = null;
|
|
59
|
+
|
|
60
|
+
public RNMappPluginModule(ReactApplicationContext reactContext) {
|
|
61
|
+
super(reactContext);
|
|
62
|
+
this.reactContext = reactContext;
|
|
63
|
+
application = (Application) reactContext.getApplicationContext();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public String getName() {
|
|
68
|
+
return "RNMappPluginModule";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public void initialize() {
|
|
73
|
+
super.initialize();
|
|
74
|
+
// application is initialized in constructor
|
|
75
|
+
/* if (getCurrentActivity() != null)
|
|
76
|
+
application = (Application) getCurrentActivity().getApplication();*/
|
|
77
|
+
getReactApplicationContext().addLifecycleEventListener(new LifecycleEventListener() {
|
|
78
|
+
@Override
|
|
79
|
+
public void onHostResume() {
|
|
80
|
+
Appoxee.engage(application);
|
|
81
|
+
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public void onHostPause() {
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public void onHostDestroy() {
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
EventEmitter.shared().attachReactContext(getReactApplicationContext());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private void reportResultWithCallback(Callback callback, String error, Object result) {
|
|
101
|
+
if (callback != null) {
|
|
102
|
+
if (error != null) {
|
|
103
|
+
callback.invoke(error);
|
|
104
|
+
} else {
|
|
105
|
+
callback.invoke(null, result);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@ReactMethod
|
|
111
|
+
public void setRemoteMessage(String msgJson) {
|
|
112
|
+
RemoteMessage remoteMessage = getRemoteMessage(msgJson);
|
|
113
|
+
if (remoteMessage != null){
|
|
114
|
+
Appoxee.instance().setRemoteMessage(remoteMessage);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactMethod
|
|
119
|
+
public void isPushFromMapp(String msgJson, Promise promise) {
|
|
120
|
+
try {
|
|
121
|
+
JSONObject json = new JSONObject(msgJson);
|
|
122
|
+
boolean mappPush = json.has("data") && json.getJSONObject("data").has("p");
|
|
123
|
+
promise.resolve(mappPush);
|
|
124
|
+
} catch (Exception e) {
|
|
125
|
+
promise.resolve(false);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ReactMethod
|
|
130
|
+
public void setToken(String token) {
|
|
131
|
+
Appoxee.instance().setToken(token);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@ReactMethod
|
|
135
|
+
public void setAlias(String alias) {
|
|
136
|
+
Appoxee.instance().setAlias(alias);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@ReactMethod
|
|
140
|
+
public void engage2() {
|
|
141
|
+
Appoxee.engage(Objects.requireNonNull(application));
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void engage(String sdkKey, String googleProjectId, String server, String appID, String tenantID) {
|
|
147
|
+
AppoxeeOptions opt = new AppoxeeOptions();
|
|
148
|
+
opt.appID = appID;
|
|
149
|
+
opt.sdkKey = sdkKey;
|
|
150
|
+
opt.googleProjectId = googleProjectId;
|
|
151
|
+
opt.server = AppoxeeOptions.Server.valueOf(server);
|
|
152
|
+
if (server.equals("TEST") || server.equals("TEST55") || server.equals("TEST_55")) {
|
|
153
|
+
opt.cepURL = "https://jamie-test.shortest-route.com";
|
|
154
|
+
}
|
|
155
|
+
opt.notificationMode = NotificationMode.BACKGROUND_AND_FOREGROUND;
|
|
156
|
+
opt.tenantID = tenantID;
|
|
157
|
+
Appoxee.engage(Objects.requireNonNull(application), opt);
|
|
158
|
+
Appoxee.instance().addInitListener(new Appoxee.OnInitCompletedListener() {
|
|
159
|
+
@Override
|
|
160
|
+
public void onInitCompleted(boolean successful, Exception failReason) {
|
|
161
|
+
/**
|
|
162
|
+
* OnInitCompleteListener must be attached;
|
|
163
|
+
* Internally {@link AppoxeeServiceAdapter#getDeviceInfoDMC()} is called and "user_id" created.
|
|
164
|
+
* If "user_id" is null InApp messages are not working.
|
|
165
|
+
*/
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@ReactMethod
|
|
173
|
+
public void engageTestServer(String cepURl, String sdkKey, String googleProjectId, String server, String appID, String tenantID) {
|
|
174
|
+
AppoxeeOptions opt = new AppoxeeOptions();
|
|
175
|
+
opt.appID = appID;
|
|
176
|
+
opt.sdkKey = sdkKey;
|
|
177
|
+
opt.googleProjectId = googleProjectId;
|
|
178
|
+
opt.server = AppoxeeOptions.Server.valueOf(server);
|
|
179
|
+
opt.cepURL = cepURl;
|
|
180
|
+
opt.tenantID = tenantID;
|
|
181
|
+
Appoxee.setOrientation(application, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
182
|
+
|
|
183
|
+
Appoxee.engage(Objects.requireNonNull(application), opt);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@ReactMethod
|
|
187
|
+
public void setPushEnabled(boolean optIn) {
|
|
188
|
+
Appoxee.instance().setPushEnabled(optIn);
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactMethod
|
|
193
|
+
public void isPushEnabled(Promise promise) {
|
|
194
|
+
promise.resolve(Appoxee.instance().isPushEnabled());
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@ReactMethod
|
|
199
|
+
public void isReady(Promise promise) {
|
|
200
|
+
promise.resolve(Appoxee.instance().isReady());
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@ReactMethod
|
|
205
|
+
public void onInitCompletedListener(final Promise promise) {
|
|
206
|
+
Appoxee.instance().addInitListener(new Appoxee.OnInitCompletedListener() {
|
|
207
|
+
@Override
|
|
208
|
+
public void onInitCompleted(boolean b, Exception e) {
|
|
209
|
+
promise.resolve(b);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
@ReactMethod
|
|
216
|
+
public void setAttribute(String key, String value) {
|
|
217
|
+
Appoxee.instance().setAttribute(key, value);
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@ReactMethod
|
|
222
|
+
public void setAttributeBoolean(String key, Boolean value) {
|
|
223
|
+
Appoxee.instance().setAttribute(key, value);
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@ReactMethod
|
|
228
|
+
public void setAttributeInt(String key, Integer value) {
|
|
229
|
+
Appoxee.instance().setAttribute(key, value);
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@ReactMethod
|
|
234
|
+
public void addTag(String tag) {
|
|
235
|
+
Appoxee.instance().addTag(tag);
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@ReactMethod
|
|
240
|
+
public void removeTag(String tag) {
|
|
241
|
+
Appoxee.instance().removeTag(tag);
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@ReactMethod
|
|
246
|
+
public void getTags(Promise promise) {
|
|
247
|
+
|
|
248
|
+
WritableArray array = Arguments.createArray();
|
|
249
|
+
for (String tag : Appoxee.instance().getTags()) {
|
|
250
|
+
array.pushString(tag);
|
|
251
|
+
}
|
|
252
|
+
promise.resolve(array);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@ReactMethod
|
|
256
|
+
public void removeAttribute(String attribute) {
|
|
257
|
+
Appoxee.instance().removeAttribute(attribute);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@ReactMethod
|
|
262
|
+
public void getAlias(Promise promise) {
|
|
263
|
+
promise.resolve(Appoxee.instance().getAlias());
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@ReactMethod
|
|
267
|
+
public void getDeviceInfo(Promise promise) {
|
|
268
|
+
promise.resolve(getDeviceInfoJson(Appoxee.instance().getDeviceInfo()));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@ReactMethod
|
|
272
|
+
public void getAttributeStringValue(String value, Promise promise) {
|
|
273
|
+
promise.resolve(Appoxee.instance().getAttributeStringValue(value));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@ReactMethod
|
|
278
|
+
public void lockScreenOrientation(Integer orientation) {
|
|
279
|
+
Appoxee.setOrientation(Objects.requireNonNull((Application) reactContext.getApplicationContext()), orientation);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@ReactMethod
|
|
283
|
+
public void removeBadgeNumber() {
|
|
284
|
+
Appoxee.removeBadgeNumber(Objects.requireNonNull((Application) reactContext.getApplicationContext()));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@ReactMethod
|
|
288
|
+
public void startGeoFencing() {
|
|
289
|
+
|
|
290
|
+
Appoxee.instance().startGeoFencing();
|
|
291
|
+
// if (Build.VERSION.SDK_INT < 23) {
|
|
292
|
+
// Appoxee.instance().startGeoFencing();
|
|
293
|
+
// } else if (Build.VERSION.SDK_INT <= 28) {
|
|
294
|
+
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
295
|
+
// new RequestPermissionsTask.Callback() {
|
|
296
|
+
// @Override
|
|
297
|
+
// public void onResult(boolean enabled) {
|
|
298
|
+
// if (enabled) {
|
|
299
|
+
//
|
|
300
|
+
// Appoxee.instance().startGeoFencing();
|
|
301
|
+
// }
|
|
302
|
+
// }
|
|
303
|
+
// });
|
|
304
|
+
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
305
|
+
//
|
|
306
|
+
// } else if (Build.VERSION.SDK_INT == 29) {
|
|
307
|
+
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
308
|
+
// new RequestPermissionsTask.Callback() {
|
|
309
|
+
// @Override
|
|
310
|
+
// public void onResult(boolean enabled) {
|
|
311
|
+
// if (enabled) {
|
|
312
|
+
//
|
|
313
|
+
// Appoxee.instance().startGeoFencing();
|
|
314
|
+
// }
|
|
315
|
+
// }
|
|
316
|
+
// });
|
|
317
|
+
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
|
318
|
+
//
|
|
319
|
+
// } else if (Build.VERSION.SDK_INT == 30) {
|
|
320
|
+
// RequestPermissionsTask task = new RequestPermissionsTask(getReactApplicationContext(),
|
|
321
|
+
// new RequestPermissionsTask.Callback() {
|
|
322
|
+
// @Override
|
|
323
|
+
// public void onResult(boolean enabled) {
|
|
324
|
+
// if (enabled) {
|
|
325
|
+
// Appoxee.instance().startGeoFencing();
|
|
326
|
+
// RequestPermissionsTask task2 = new RequestPermissionsTask(getReactApplicationContext(),
|
|
327
|
+
// new RequestPermissionsTask.Callback() {
|
|
328
|
+
// @Override
|
|
329
|
+
// public void onResult(boolean enabled) {
|
|
330
|
+
// if (enabled) {
|
|
331
|
+
// Appoxee.instance().startGeoFencing();
|
|
332
|
+
// }
|
|
333
|
+
// }
|
|
334
|
+
// });
|
|
335
|
+
// task2.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
|
336
|
+
//
|
|
337
|
+
// }
|
|
338
|
+
// }
|
|
339
|
+
// });
|
|
340
|
+
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
341
|
+
// }
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@ReactMethod
|
|
346
|
+
public void stopGeoFencing() {
|
|
347
|
+
Appoxee.instance().stopGeoFencing();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@ReactMethod
|
|
351
|
+
public void fetchInboxMessage(final Promise promise) {
|
|
352
|
+
|
|
353
|
+
Appoxee.instance().fetchInboxMessages(reactContext.getApplicationContext());
|
|
354
|
+
|
|
355
|
+
InAppInboxCallback inAppInboxCallback = new InAppInboxCallback();
|
|
356
|
+
inAppInboxCallback.addInAppInboxMessagesReceivedCallback(new InAppInboxCallback.onInAppInboxMessagesReceived() {
|
|
357
|
+
@Override
|
|
358
|
+
public void onInAppInboxMessages(List<APXInboxMessage> richMessages) {
|
|
359
|
+
WritableArray messagesArray = Arguments.createArray();
|
|
360
|
+
if (richMessages != null)
|
|
361
|
+
for (APXInboxMessage message : richMessages) {
|
|
362
|
+
messagesArray.pushMap(messageToJson(message));
|
|
363
|
+
}
|
|
364
|
+
promise.resolve(messagesArray);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@Override
|
|
368
|
+
public void onInAppInboxMessage(final APXInboxMessage message) {
|
|
369
|
+
promise.resolve(messageToJson(message));
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@ReactMethod
|
|
377
|
+
public void triggerInApp(String key) {
|
|
378
|
+
Appoxee.instance().triggerInApp((getCurrentActivity()), key);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@ReactMethod
|
|
382
|
+
public void inAppMarkAsRead(Integer templateId, String eventId) {
|
|
383
|
+
Appoxee.instance().triggerStatistcs((getCurrentActivity()), getInAppStatisticsRequestObject(templateId,
|
|
384
|
+
eventId,
|
|
385
|
+
InAppStatistics.INBOX_INBOX_MESSAGE_READ_KEY, null, null, null));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
@ReactMethod
|
|
389
|
+
public void inAppMarkAsUnRead(Integer templateId, String eventId) {
|
|
390
|
+
Appoxee.instance().triggerStatistcs((reactContext.getApplicationContext()), getInAppStatisticsRequestObject(templateId,
|
|
391
|
+
eventId,
|
|
392
|
+
InAppStatistics.INBOX_INBOX_MESSAGE_UNREAD_KEY, null, null, null));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
@ReactMethod
|
|
396
|
+
public void inAppMarkAsDeleted(Integer templateId, String eventId) {
|
|
397
|
+
Appoxee.instance().triggerStatistcs((reactContext.getApplicationContext()), getInAppStatisticsRequestObject(templateId,
|
|
398
|
+
eventId,
|
|
399
|
+
InAppStatistics.INBOX_INBOX_MESSAGE_DELETED_KEY, null, null, null));
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
@ReactMethod
|
|
403
|
+
public void triggerStatistic(Integer templateId, String originalEventId,
|
|
404
|
+
String trackingKey, Long displayMillis,
|
|
405
|
+
String reason, String link) {
|
|
406
|
+
Appoxee.instance()
|
|
407
|
+
.triggerStatistcs((reactContext.getApplicationContext())
|
|
408
|
+
, getInAppStatisticsRequestObject(templateId, originalEventId, trackingKey, displayMillis, reason, link));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
@ReactMethod
|
|
412
|
+
public void isDeviceRegistered(Promise promise) {
|
|
413
|
+
promise.resolve(Appoxee.instance().isDeviceRegistered());
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
@ReactMethod
|
|
419
|
+
public void addAndroidListener(String eventName) {
|
|
420
|
+
EventEmitter.shared().addAndroidListener(eventName);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
@ReactMethod
|
|
424
|
+
public void removeAndroidListeners(int count) {
|
|
425
|
+
EventEmitter.shared().removeAndroidListeners(count);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
private static InAppStatistics getInAppStatisticsRequestObject(int templateId, String originalEventId,
|
|
430
|
+
String trackingKey, Long displayMillis,
|
|
431
|
+
String reason, String link) {
|
|
432
|
+
|
|
433
|
+
InAppStatistics inAppStatistics = new InAppStatistics();
|
|
434
|
+
//This will be received from the respective Screens.
|
|
435
|
+
MessageContext mc = new MessageContext();
|
|
436
|
+
mc.setTemplateId(templateId);
|
|
437
|
+
mc.setOriginialEventid(originalEventId);
|
|
438
|
+
inAppStatistics.setMessageContext(mc);
|
|
439
|
+
Tracking tk = new Tracking();
|
|
440
|
+
tk.setTrackingKey(trackingKey);
|
|
441
|
+
TrackingAttributes ta = new TrackingAttributes();
|
|
442
|
+
ta.setTimeSinceDisplayMillis(displayMillis);
|
|
443
|
+
ta.setReason(reason);
|
|
444
|
+
ta.setLink(link);
|
|
445
|
+
tk.setTrackingAttributes(ta);
|
|
446
|
+
inAppStatistics.setTracking(tk);
|
|
447
|
+
|
|
448
|
+
return inAppStatistics;
|
|
449
|
+
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
private WritableMap messageToJson(APXInboxMessage msg) {
|
|
454
|
+
WritableMap msgJson = new WritableNativeMap();
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
msgJson.putInt("templateId", msg.getTemplateId());
|
|
458
|
+
msgJson.putString("title", msg.getContent());
|
|
459
|
+
msgJson.putString("eventId", msg.getEventId());
|
|
460
|
+
if (msg.getExpirationDate() != null)
|
|
461
|
+
msgJson.putString("expirationDate", msg.getExpirationDate().toString());
|
|
462
|
+
if (msg.getIconUrl() != null)
|
|
463
|
+
msgJson.putString("iconURl", msg.getIconUrl());
|
|
464
|
+
if (msg.getStatus() != null)
|
|
465
|
+
msgJson.putString("status", msg.getStatus());
|
|
466
|
+
if (msg.getSubject() != null)
|
|
467
|
+
msgJson.putString("subject", msg.getSubject());
|
|
468
|
+
if (msg.getSummary() != null)
|
|
469
|
+
msgJson.putString("summary", msg.getSummary());
|
|
470
|
+
if (msg.getExtras() != null)
|
|
471
|
+
for (ApxInAppExtras apxInAppExtras : msg.getExtras())
|
|
472
|
+
msgJson.putString(apxInAppExtras.getName(), apxInAppExtras.getValue());
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
} catch (Exception e) {
|
|
476
|
+
e.printStackTrace();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return msgJson;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
private WritableMap getDeviceInfoJson(DeviceInfo deviceInfoList) {
|
|
484
|
+
WritableMap deviceInfo = new WritableNativeMap();
|
|
485
|
+
try {
|
|
486
|
+
deviceInfo.putString("id", deviceInfoList.id);
|
|
487
|
+
deviceInfo.putString("appVersion", deviceInfoList.appVersion);
|
|
488
|
+
deviceInfo.putString("sdkVersion", deviceInfoList.sdkVersion);
|
|
489
|
+
deviceInfo.putString("locale", deviceInfoList.locale);
|
|
490
|
+
deviceInfo.putString("timezone", deviceInfoList.timezone);
|
|
491
|
+
deviceInfo.putString("deviceModel", deviceInfoList.deviceModel);
|
|
492
|
+
deviceInfo.putString("manufacturer", deviceInfoList.manufacturer);
|
|
493
|
+
deviceInfo.putString("osVersion", deviceInfoList.osVersion);
|
|
494
|
+
deviceInfo.putString("resolution", deviceInfoList.resolution);
|
|
495
|
+
deviceInfo.putString("density", String.valueOf(deviceInfoList.density));
|
|
496
|
+
} catch (Exception e) {
|
|
497
|
+
e.printStackTrace();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return deviceInfo;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
public static WritableMap getPushMessageToJSon(PushData pushData) {
|
|
505
|
+
WritableMap deviceInfo = new WritableNativeMap();
|
|
506
|
+
try {
|
|
507
|
+
deviceInfo.putString("id", String.valueOf(pushData.id));
|
|
508
|
+
deviceInfo.putString("title", pushData.title);
|
|
509
|
+
deviceInfo.putString("bigText", pushData.bigText);
|
|
510
|
+
deviceInfo.putString("sound", pushData.sound);
|
|
511
|
+
if (pushData.actionUri != null)
|
|
512
|
+
deviceInfo.putString("actionUri", pushData.actionUri.toString());
|
|
513
|
+
deviceInfo.putString("collapseKey", pushData.collapseKey);
|
|
514
|
+
deviceInfo.putInt("badgeNumber", pushData.badgeNumber);
|
|
515
|
+
deviceInfo.putString("silentType", pushData.silentType);
|
|
516
|
+
deviceInfo.putString("silentData", pushData.silentData);
|
|
517
|
+
deviceInfo.putString("category", pushData.category);
|
|
518
|
+
if (pushData.extraFields != null)
|
|
519
|
+
for (Map.Entry<String, String> entry : pushData.extraFields.entrySet()) {
|
|
520
|
+
String key = entry.getKey();
|
|
521
|
+
String value = entry.getValue();
|
|
522
|
+
deviceInfo.putString(key, value);
|
|
523
|
+
}
|
|
524
|
+
} catch (Exception e) {
|
|
525
|
+
e.printStackTrace();
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return deviceInfo;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
private RemoteMessage getRemoteMessage(String jsonMsg) {
|
|
532
|
+
if (jsonMsg == null)
|
|
533
|
+
return null;
|
|
534
|
+
|
|
535
|
+
final String KEY_TOKEN = "token";
|
|
536
|
+
final String KEY_COLLAPSE_KEY = "collapseKey";
|
|
537
|
+
final String KEY_DATA = "data";
|
|
538
|
+
final String KEY_FROM = "from";
|
|
539
|
+
final String KEY_MESSAGE_ID = "messageId";
|
|
540
|
+
final String KEY_MESSAGE_TYPE = "messageType";
|
|
541
|
+
final String KEY_SENT_TIME = "sentTime";
|
|
542
|
+
final String KEY_ERROR = "error";
|
|
543
|
+
final String KEY_TO = "to";
|
|
544
|
+
final String KEY_TTL = "ttl";
|
|
545
|
+
|
|
546
|
+
JSONObject json = null;
|
|
547
|
+
try {
|
|
548
|
+
json = new JSONObject(jsonMsg);
|
|
549
|
+
|
|
550
|
+
String collapseKey = json.has(KEY_COLLAPSE_KEY) ? json.getString(KEY_COLLAPSE_KEY) : "";
|
|
551
|
+
String messageId = json.has(KEY_MESSAGE_ID) ? json.getString(KEY_MESSAGE_ID) : "";
|
|
552
|
+
String messageType = json.has(KEY_MESSAGE_TYPE) ? json.getString(KEY_MESSAGE_TYPE) : "";
|
|
553
|
+
int ttl = json.has(KEY_TTL) ? json.getInt(KEY_TTL) : 0;
|
|
554
|
+
JSONObject data = json.has(KEY_DATA) ? json.getJSONObject(KEY_DATA) : null;
|
|
555
|
+
|
|
556
|
+
RemoteMessage.Builder builder = new RemoteMessage.Builder("appoxee@gcm.googleapis.com")
|
|
557
|
+
.setMessageType(messageType)
|
|
558
|
+
.setMessageId(messageId)
|
|
559
|
+
.setTtl(ttl)
|
|
560
|
+
.setCollapseKey(collapseKey);
|
|
561
|
+
|
|
562
|
+
if (data != null) {
|
|
563
|
+
for (Iterator<String> it = data.keys(); it.hasNext();) {
|
|
564
|
+
String k = it.next();
|
|
565
|
+
builder.addData(k, data.getString(k));
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return builder.build();
|
|
570
|
+
} catch (JSONException e) {
|
|
571
|
+
e.printStackTrace();
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
private boolean shouldRequestLocationPermissions() {
|
|
577
|
+
if (Build.VERSION.SDK_INT < 23) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return ContextCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED &&
|
|
582
|
+
ContextCompat.checkSelfPermission(getReactApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
@ReactMethod
|
|
586
|
+
public void clearNotifications() {
|
|
587
|
+
NotificationManagerCompat.from(reactContext.getApplicationContext()).cancelAll();
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
@ReactMethod
|
|
592
|
+
public void clearNotification(int id) {
|
|
593
|
+
NotificationManagerCompat.from(reactContext.getApplicationContext()).cancel(id);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
@ReactMethod
|
|
597
|
+
public void logOut(boolean pushEnabled) {
|
|
598
|
+
Appoxee.instance().logOut(application, pushEnabled);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
|
|
602
602
|
}
|