react-native-moengage-geofence 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 07-05-2024
2
+
3
+ ## 5.0.0
4
+ - Added support for Turbo Architecture
5
+ - Android
6
+ - Making `geofence` dependecies as implementation
7
+
8
+ # 08-04-2024
9
+
10
+ ## 4.1.0
11
+ - iOS
12
+ - MoEngageGeofence SDK version updated to `~>5.16.0`.
13
+
1
14
  # 18-03-2024
2
15
 
3
16
  ## 4.0.1
@@ -13,8 +13,8 @@ Pod::Spec.new do |s|
13
13
  s.authors = "MoEngage Inc."
14
14
  s.source = {:file => './' }
15
15
  s.platform = :ios, "11.0"
16
- s.dependency 'MoEngagePluginGeofence', '>=2.7.0', '< 2.8.0'
16
+ s.dependency 'MoEngagePluginGeofence', '>=2.8.0', '< 2.9.0'
17
17
  s.dependency 'React'
18
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
-
19
+ install_modules_dependencies(s)
20
20
  end
@@ -13,8 +13,16 @@ buildscript {
13
13
  }
14
14
  }
15
15
 
16
+ ext {
17
+ //dependency version
18
+ moengageCoreVersion = "13.00.03"
19
+ moengageGeofenceVersion = "4.0.1"
20
+ pluginBaseGeofenceVersion = "2.0.0"
21
+ }
22
+
16
23
  apply plugin: 'com.android.library'
17
24
  apply plugin: 'kotlin-android'
25
+ apply plugin: 'com.facebook.react'
18
26
 
19
27
  android {
20
28
  compileSdk 33
@@ -23,6 +31,8 @@ android {
23
31
  minSdk 21
24
32
  versionCode 1
25
33
  versionName "1.0"
34
+
35
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
26
36
  }
27
37
 
28
38
  buildTypes {
@@ -41,6 +51,21 @@ android {
41
51
  kotlinOptions {
42
52
  freeCompilerArgs = ['-Xjvm-default=all']
43
53
  }
54
+
55
+ buildFeatures {
56
+ buildConfig true
57
+ }
58
+
59
+
60
+ sourceSets {
61
+ main {
62
+ if (isNewArchitectureEnabled()) {
63
+ java.srcDirs += ['src/newarch']
64
+ } else {
65
+ java.srcDirs += ['src/oldarch']
66
+ }
67
+ }
68
+ }
44
69
  }
45
70
 
46
71
  repositories {
@@ -50,9 +75,13 @@ repositories {
50
75
 
51
76
  dependencies {
52
77
  // noinspection GradleDynamicVersion
53
- compileOnly 'com.facebook.react:react-native:+'
78
+ compileOnly('com.facebook.react:react-native')
54
79
  compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
55
- compileOnly("com.moengage:moe-android-sdk:13.00.01")
56
- compileOnly("com.moengage:geofence:4.0.0")
57
- implementation("com.moengage:plugin-base-geofence:2.0.0")
80
+ compileOnly("com.moengage:moe-android-sdk:$moengageCoreVersion")
81
+ api("com.moengage:geofence:$moengageGeofenceVersion")
82
+ implementation("com.moengage:plugin-base-geofence:$pluginBaseGeofenceVersion")
58
83
  }
84
+
85
+ def isNewArchitectureEnabled() {
86
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
87
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
14
+ package com.moengage.react.geofence
15
+
16
+ import android.content.Context
17
+ import com.moengage.core.internal.logger.Logger
18
+ import com.moengage.core.LogLevel
19
+ import com.moengage.plugin.base.geofence.internal.GeofencePluginHelper
20
+
21
+ /**
22
+ * Class to handle all the request from the [MoEReactGeofence] from both old and new arch
23
+ *
24
+ * @author Abhishek Kumar
25
+ * @since Todo: Add Version
26
+ */
27
+ internal class MoEngageGeofenceHandler(private val context: Context) {
28
+
29
+ private val tag = "MoEngageGeofenceHandler"
30
+
31
+ private val pluginHelper = GeofencePluginHelper()
32
+
33
+ fun getName() = NAME
34
+
35
+ fun startGeofenceMonitoring(payload: String) {
36
+ try {
37
+ Logger.print { "$tag startGeofenceMonitoring() - $payload" }
38
+ pluginHelper.startGeofenceMonitoring(context, payload)
39
+ } catch (t: Throwable) {
40
+ Logger.print(LogLevel.ERROR, t) { "$tag startGeofenceMonitoring() : " }
41
+ }
42
+ }
43
+
44
+ fun stopGeofenceMonitoring(payload: String) {
45
+ try {
46
+ Logger.print { "$tag stopGeofenceMonitoring() - $payload" }
47
+ pluginHelper.stopGeofenceMonitoring(context, payload)
48
+ } catch (t: Throwable) {
49
+ Logger.print(LogLevel.ERROR, t) { "$tag stopGeofenceMonitoring() : " }
50
+ }
51
+ }
52
+
53
+ companion object {
54
+ const val NAME = "MoEReactGeofence"
55
+ }
56
+ }
@@ -1,20 +1,47 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
1
14
  package com.moengage.react.geofence
2
15
 
3
- import com.facebook.react.ReactPackage
16
+ import com.facebook.react.TurboReactPackage
4
17
  import com.facebook.react.bridge.NativeModule
5
18
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
19
+ import com.facebook.react.module.model.ReactModuleInfo
20
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
21
 
22
+ class MoengageGeofencePackage : TurboReactPackage() {
8
23
 
9
- class MoengageGeofencePackage : ReactPackage {
10
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
- return listOf(MoEngageGeofence(reactContext))
24
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
25
+ return if (name == MoEngageGeofenceHandler.NAME) {
26
+ MoEReactGeofence(reactContext)
27
+ } else {
28
+ null
29
+ }
12
30
  }
13
31
 
14
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
- return emptyList()
32
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
33
+ return ReactModuleInfoProvider {
34
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
35
+ val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
36
+ moduleInfos[MoEngageGeofenceHandler.NAME] = ReactModuleInfo(
37
+ MoEngageGeofenceHandler.NAME,
38
+ MoEngageGeofenceHandler.NAME,
39
+ false, // canOverrideExistingModule
40
+ false, // needsEagerInit
41
+ false, // isCxxModule
42
+ isTurboModule // isTurboModule
43
+ )
44
+ moduleInfos
45
+ }
16
46
  }
17
- }
18
-
19
-
20
-
47
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
14
+ package com.moengage.react.geofence
15
+
16
+ import com.facebook.react.bridge.ReactApplicationContext
17
+
18
+ /**
19
+ * Bridge to communicate with React-Native Goefence Plugin in new arch
20
+ *
21
+ * @author Abhishek Kumar
22
+ * @since Todo: Add Version
23
+ */
24
+ class MoEReactGeofence(reactContext: ReactApplicationContext) :
25
+ NativeMoEngageGeofenceSpec(reactContext) {
26
+
27
+ private val bridgeHandler = MoEngageGeofenceHandler(reactContext.applicationContext)
28
+
29
+ override fun getName() = bridgeHandler.getName()
30
+
31
+ override fun startGeofenceMonitoring(payload: String) {
32
+ bridgeHandler.startGeofenceMonitoring(payload)
33
+ }
34
+
35
+ override fun stopGeofenceMonitoring(payload: String) {
36
+ bridgeHandler.stopGeofenceMonitoring(payload)
37
+ }
38
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
14
+ package com.moengage.react.geofence
15
+
16
+ import com.facebook.react.bridge.ReactApplicationContext
17
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
18
+ import com.facebook.react.bridge.ReactMethod
19
+ import com.moengage.core.internal.logger.Logger
20
+ import com.moengage.core.LogLevel
21
+ import com.moengage.plugin.base.geofence.internal.GeofencePluginHelper
22
+
23
+ /**
24
+ * Bridge to communicate with js code in old arch
25
+ *
26
+ * @author Abhishek Kumar
27
+ * @since Todo: Add Version
28
+ */
29
+ class MoEReactGeofence(
30
+ reactContext: ReactApplicationContext
31
+ ) : ReactContextBaseJavaModule(reactContext) {
32
+
33
+ private val bridgeHandler = MoEngageGeofenceHandler(reactContext.applicationContext)
34
+
35
+ override fun getName() = bridgeHandler.getName()
36
+
37
+ @ReactMethod
38
+ fun startGeofenceMonitoring(payload: String) {
39
+ bridgeHandler.startGeofenceMonitoring(payload)
40
+ }
41
+
42
+ @ReactMethod
43
+ fun stopGeofenceMonitoring(payload: String) {
44
+ bridgeHandler.stopGeofenceMonitoring(payload)
45
+ }
46
+ }
@@ -1,6 +1,14 @@
1
1
 
2
2
  #import <React/RCTBridgeModule.h>
3
- @import MoEngagePluginGeofence;
4
- @interface MoEReactGeofence : NSObject <RCTBridgeModule>
5
3
 
4
+ #ifdef RCT_NEW_ARCH_ENABLED
5
+ #import <NativeMoEngageGeofenceSpec/NativeMoEngageGeofenceSpec.h>
6
+ #endif
7
+
8
+ #ifdef RCT_NEW_ARCH_ENABLED
9
+ @interface MoEReactGeofence : NSObject <NativeMoEngageGeofenceSpec>
10
+ @end
11
+ #else
12
+ @interface MoEReactGeofence : NSObject <RCTBridgeModule>
6
13
  @end
14
+ #endif
@@ -0,0 +1,28 @@
1
+ //
2
+ // MoEReactGeofence.h
3
+ // ReactNativeMoEngageGeofence
4
+ //
5
+ // Created by Rakshitha on 14/03/24.
6
+ //
7
+
8
+ #import "MoEReactGeofence.h"
9
+ #import "MoEReactNativeGeofenceHandler.h"
10
+
11
+ @implementation MoEReactGeofence
12
+
13
+ RCT_EXPORT_MODULE()
14
+ RCT_EXPORT_METHOD(startGeofenceMonitoring:(NSString *) payload) {
15
+ [[MoEReactNativeGeofenceHandler sharedInstance] startGeofenceMonitoring:payload];
16
+ }
17
+
18
+ RCT_EXPORT_METHOD(stopGeofenceMonitoring:(NSString *) payload) {
19
+ [[MoEReactNativeGeofenceHandler sharedInstance] stopGeofenceMonitoring:payload];
20
+ }
21
+
22
+ #ifdef RCT_NEW_ARCH_ENABLED
23
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
24
+ return std::make_shared<facebook::react::NativeMoEngageGeofenceSpecJSI>(params);
25
+ }
26
+ #endif
27
+
28
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // MoEReactNativeGeofenceHandler.h
3
+ // ReactNativeMoEngageGeofence
4
+ //
5
+ // Created by Rakshitha on 14/03/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <UIKit/UIKit.h>
10
+
11
+ @interface MoEReactNativeGeofenceHandler: NSObject
12
+ +(instancetype)sharedInstance;
13
+
14
+ -(void)startGeofenceMonitoring:(NSString *)payload;
15
+ -(void)stopGeofenceMonitoring:(NSString *)payload;
16
+ @end
17
+
@@ -0,0 +1,39 @@
1
+ //
2
+ // MoEReactNativeHandler.m
3
+ // ReactNativeMoEngageGeofence
4
+ //
5
+ // Created by Rakshitha on 14/03/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "MoEReactNativeGeofenceHandler.h"
10
+ #import "ReactNativeMoEngage/MoEngageReactUtils.h"
11
+
12
+ @import MoEngagePluginGeofence;
13
+
14
+ @interface MoEReactNativeGeofenceHandler()
15
+ @end
16
+
17
+ @implementation MoEReactNativeGeofenceHandler : NSObject
18
+
19
+ +(instancetype)sharedInstance{
20
+ static dispatch_once_t onceToken;
21
+ static MoEReactNativeGeofenceHandler *instance;
22
+ dispatch_once(&onceToken, ^{
23
+ instance = [[MoEReactNativeGeofenceHandler alloc] init];
24
+ });
25
+ return instance;
26
+ }
27
+
28
+ // MARK: Geofence methods
29
+ -(void)startGeofenceMonitoring:(NSString *)payload {
30
+ NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
31
+ [[MoEngagePluginGeofenceBridge sharedInstance] startGeofenceMonitoring: jsonPayload];
32
+ }
33
+
34
+ -(void)stopGeofenceMonitoring:(NSString *)payload {
35
+ NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
36
+ [[MoEngagePluginGeofenceBridge sharedInstance] stopGeofenceMonitoring: jsonPayload];
37
+ }
38
+
39
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage-geofence",
3
- "version": "4.0.1",
3
+ "version": "5.0.0",
4
4
  "description": "MoEngage React Native package to support geofence based campaigns in iOS platform",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -14,7 +14,7 @@
14
14
  "!**/__mocks__"
15
15
  ],
16
16
  "peerDependencies": {
17
- "react-native-moengage": "^9.0.0"
17
+ "react-native-moengage": "^10.0.0"
18
18
  },
19
19
  "keywords": [
20
20
  "moengage",
@@ -37,5 +37,13 @@
37
37
  "license": "SEE LICENSE IN LICENSE.txt",
38
38
  "devDependencies": {
39
39
  "@types/react-native": "^0.69.3"
40
+ },
41
+ "codegenConfig": {
42
+ "name": "NativeMoEngageGeofenceSpec",
43
+ "type": "modules",
44
+ "jsSrcsDir": "src",
45
+ "android": {
46
+ "javaPackageName": "com.moengage.react.geofence"
47
+ }
40
48
  }
41
49
  }
@@ -0,0 +1,22 @@
1
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+
6
+ /**
7
+ * Call this method to start Geofence tracking.
8
+ *
9
+ * @param payload Stringified JSON Payload
10
+ */
11
+ startGeofenceMonitoring: (payload: string) => void;
12
+
13
+ /**
14
+ * Call this method to stop Geofence tracking
15
+ *
16
+ * @param payload Stringified JSON Payload
17
+ */
18
+ stopGeofenceMonitoring: (payload: string) => void;
19
+ }
20
+
21
+ const MoEReactGeofence = TurboModuleRegistry.getEnforcing<Spec>('MoEReactGeofence');
22
+ export default MoEReactGeofence;
package/src/index.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import { Platform } from "react-native";
2
2
 
3
3
  import { MoEngageLogger } from "react-native-moengage";
4
- import * as MoEGeofenceRNiOS from "./platform/MoEGeofenceRNiOS";
5
- import { MoEGeofenceRNAndroid } from "./platform/MoEGeofenceRNAndroid";
6
-
7
- const PLATFORM_ANDROID = "android";
8
- const PLATFORM_iOS = "ios";
4
+ import MoEReactGeofence from './NativeMoEngageGeofence';
5
+ import { getAppIdJson } from "./utils/MoEGeofenceJsonBuilder";
9
6
 
10
7
  var ReactMoEGeofence = {
11
8
 
@@ -17,11 +14,7 @@ var ReactMoEGeofence = {
17
14
  */
18
15
  startGeofenceMonitoring: function (appId: string) {
19
16
  MoEngageLogger.verbose("Will start geofence monitoring");
20
- if (Platform.OS == PLATFORM_iOS) {
21
- MoEGeofenceRNiOS.startGeofenceMonitoring(appId);
22
- } else if (Platform.OS == PLATFORM_ANDROID) {
23
- MoEGeofenceRNAndroid.startGeofenceMonitoring(appId);
24
- }
17
+ MoEReactGeofence.startGeofenceMonitoring(getAppIdJson(appId));
25
18
  },
26
19
 
27
20
  /**
@@ -32,11 +25,7 @@ var ReactMoEGeofence = {
32
25
  */
33
26
  stopGeofenceMonitoring: function (appId: string) {
34
27
  MoEngageLogger.verbose("Will stop geofence monitoring");
35
- if (Platform.OS == PLATFORM_ANDROID) {
36
- MoEGeofenceRNAndroid.stopGeofenceMonitoring(appId);
37
- } else if (Platform.OS == PLATFORM_iOS) {
38
- MoEGeofenceRNiOS.stopGeofenceMonitoring(appId)
39
- }
28
+ MoEReactGeofence.stopGeofenceMonitoring(getAppIdJson(appId));
40
29
  }
41
30
 
42
31
  }
@@ -1,8 +1,8 @@
1
1
  export function getAppIdJson(appId: String) {
2
- var json: { [k: string]: any } = {
2
+ let json: { [k: string]: any } = {
3
3
  accountMeta: {
4
4
  appId: appId
5
5
  }
6
6
  }
7
- return json;
7
+ return JSON.stringify(json);
8
8
  }
@@ -1,41 +0,0 @@
1
- package com.moengage.react.geofence
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.bridge.ReactContextBaseJavaModule
5
- import com.facebook.react.bridge.ReactMethod
6
- import com.moengage.core.internal.logger.Logger
7
- import com.moengage.core.LogLevel
8
- import com.moengage.plugin.base.geofence.internal.GeofencePluginHelper
9
-
10
- class MoEngageGeofence(reactContext: ReactApplicationContext) :
11
- ReactContextBaseJavaModule(reactContext) {
12
-
13
- private val tag = "MoEngageGeofence"
14
-
15
- private val context = reactContext.applicationContext
16
- private val pluginHelper = GeofencePluginHelper()
17
-
18
- override fun getName(): String {
19
- return "MoEngageGeofence"
20
- }
21
-
22
- @ReactMethod
23
- fun startGeofenceMonitoring(payload: String) {
24
- try {
25
- Logger.print { "$tag startGeofenceMonitoring()" }
26
- pluginHelper.startGeofenceMonitoring(context, payload)
27
- } catch (t: Throwable) {
28
- Logger.print(LogLevel.ERROR, t) { "$tag startGeofenceMonitoring() : " }
29
- }
30
- }
31
-
32
- @ReactMethod
33
- fun stopGeofenceMonitoring(payload: String) {
34
- try {
35
- Logger.print { "$tag stopGeofenceMonitoring()" }
36
- pluginHelper.stopGeofenceMonitoring(context, payload)
37
- } catch (t: Throwable) {
38
- Logger.print(LogLevel.ERROR, t) { "$tag stopGeofenceMonitoring() : " }
39
- }
40
- }
41
- }
@@ -1,14 +0,0 @@
1
- #import "MoEReactGeofence.h"
2
-
3
- @implementation MoEReactGeofence
4
-
5
- RCT_EXPORT_MODULE()
6
- RCT_EXPORT_METHOD(startGeofenceMonitoring:(NSDictionary *) payload) {
7
- [[MoEngagePluginGeofenceBridge sharedInstance] startGeofenceMonitoring: payload];
8
- }
9
-
10
- RCT_EXPORT_METHOD(stopGeofenceMonitoring:(NSDictionary *) payload) {
11
- [[MoEngagePluginGeofenceBridge sharedInstance] stopGeofenceMonitoring:payload];
12
- }
13
-
14
- @end
@@ -1,14 +0,0 @@
1
- import { getAppIdJson } from "../utils/MoEGeofenceJsonBuilder";
2
-
3
- const MoEGeofenceBridge = require("react-native").NativeModules.MoEngageGeofence;
4
-
5
- export class MoEGeofenceRNAndroid {
6
-
7
- static startGeofenceMonitoring(appId:string) {
8
- MoEGeofenceBridge.startGeofenceMonitoring(JSON.stringify(getAppIdJson(appId)));
9
- }
10
-
11
- static stopGeofenceMonitoring(appId:string) {
12
- MoEGeofenceBridge.stopGeofenceMonitoring(JSON.stringify(getAppIdJson(appId)));
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- import { getAppIdJson } from "../utils/MoEGeofenceJsonBuilder";
2
-
3
- const MoEGeofenceBridge = require("react-native").NativeModules.MoEReactGeofence;
4
-
5
- export const startGeofenceMonitoring = (appId: string) => {
6
- MoEGeofenceBridge.startGeofenceMonitoring(getAppIdJson(appId));
7
- }
8
-
9
- export const stopGeofenceMonitoring = (appId: string) => {
10
- MoEGeofenceBridge.stopGeofenceMonitoring(getAppIdJson(appId));
11
- }