diff --git a/android/src/main/java/com/mparticle/react/MParticleModule.java b/android/src/main/java/com/mparticle/react/MParticleModule.java index 719519d..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; @@ -73,6 +74,15 @@ public void setUploadInterval(int uploadInterval) { MParticle.getInstance().setUpdateInterval(uploadInterval); } + @ReactMethod + public void setLocation(double latitude, double longitude) { + Location newLocation = new Location(""); + newLocation.setLatitude(latitude); + newLocation.setLongitude(longitude); + MParticle.getInstance().setLocation(newLocation); + + } + @ReactMethod public void logEvent(final String name, int type, final ReadableMap attributesMap) { Map attributes = ConvertStringMap(attributesMap); diff --git a/ios/RNMParticle/RNMParticle.m b/ios/RNMParticle/RNMParticle.m index bcab350..d90f2cc 100644 --- a/ios/RNMParticle/RNMParticle.m +++ b/ios/RNMParticle/RNMParticle.m @@ -30,6 +30,12 @@ + (void)load { [[MParticle sharedInstance] upload]; } +RCT_EXPORT_METHOD(setLocation:(double)latitude longitude:(double)longitude) +{ + CLLocation *newLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude]; + [MParticle sharedInstance].location = newLocation; +} + RCT_EXPORT_METHOD(setUploadInterval:(NSInteger)uploadInterval) { [[MParticle sharedInstance] setUploadInterval:uploadInterval]; diff --git a/js/index.js b/js/index.js index fe8aa88..f2ed42b 100644 --- a/js/index.js +++ b/js/index.js @@ -158,6 +158,10 @@ const getSession = (completion) => { NativeModules.MParticle.getSession(completion) } +const setLocation = (latitude, longitude) => { + NativeModules.MParticle.setLocation(latitude, longitude) +} + // ******** Identity ******** class User { constructor (userId) { @@ -686,7 +690,8 @@ const MParticle = { isKitActive, getAttributions, logPushRegistration, - getSession + getSession, + setLocation } export default MParticle