From e7ba93efc09cb6a627ccf118a88ceaa5758fd0af Mon Sep 17 00:00:00 2001 From: AjilJagadeesh7 Date: Thu, 29 Feb 2024 13:27:40 +0530 Subject: [PATCH] updated pr based on comments | split location to latitude and longitude --- .../main/java/com/mparticle/react/MParticleModule.java | 9 +++++++-- ios/RNMParticle/RNMParticle.m | 3 ++- js/index.js | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/mparticle/react/MParticleModule.java b/android/src/main/java/com/mparticle/react/MParticleModule.java index 44f935e..0f45f15 100644 --- a/android/src/main/java/com/mparticle/react/MParticleModule.java +++ b/android/src/main/java/com/mparticle/react/MParticleModule.java @@ -1,5 +1,6 @@ package com.mparticle.react; +import android.location.Location; import android.util.Log; import com.facebook.react.bridge.Arguments; @@ -74,8 +75,12 @@ public void setUploadInterval(int uploadInterval) { } @ReactMethod - public void setLocation(final android.location.Location location) { - MParticle.getInstance().setLocation(location); + public void setLocation(double latitude, double longitude) { + Location newLocation = new Location(""); + newLocation.setLatitude(latitude); + newLocation.setLongitude(longitude); + MParticle.getInstance().setLocation(newLocation); + } @ReactMethod diff --git a/ios/RNMParticle/RNMParticle.m b/ios/RNMParticle/RNMParticle.m index e0bfe5d..d90f2cc 100644 --- a/ios/RNMParticle/RNMParticle.m +++ b/ios/RNMParticle/RNMParticle.m @@ -30,8 +30,9 @@ + (void)load { [[MParticle sharedInstance] upload]; } -RCT_EXPORT_METHOD(setLocation:(CLLocation *)newLocation) +RCT_EXPORT_METHOD(setLocation:(double)latitude longitude:(double)longitude) { + CLLocation *newLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude]; [MParticle sharedInstance].location = newLocation; } diff --git a/js/index.js b/js/index.js index 76e4421..c59c93d 100644 --- a/js/index.js +++ b/js/index.js @@ -158,8 +158,8 @@ const getSession = (completion) => { NativeModules.MParticle.getSession(completion) } -const setLocation = (location) => { - NativeModules.MParticle.setLocation(location); +const setLocation = (latitude, longitude) => { + NativeModules.MParticle.setLocation(latitude, longitude); }; // ******** Identity ********