File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
android/src/main/java/com/mparticle/react Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 11package com .mparticle .react ;
22
3+ import android .location .Location ;
34import android .util .Log ;
45
56import com .facebook .react .bridge .Arguments ;
@@ -73,6 +74,15 @@ public void setUploadInterval(int uploadInterval) {
7374 MParticle .getInstance ().setUpdateInterval (uploadInterval );
7475 }
7576
77+ @ ReactMethod
78+ public void setLocation (double latitude , double longitude ) {
79+ Location newLocation = new Location ("" );
80+ newLocation .setLatitude (latitude );
81+ newLocation .setLongitude (longitude );
82+ MParticle .getInstance ().setLocation (newLocation );
83+
84+ }
85+
7686 @ ReactMethod
7787 public void logEvent (final String name , int type , final ReadableMap attributesMap ) {
7888 Map <String , String > attributes = ConvertStringMap (attributesMap );
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ + (void)load {
3030 [[MParticle sharedInstance ] upload ];
3131}
3232
33+ RCT_EXPORT_METHOD (setLocation:(double )latitude longitude:(double )longitude)
34+ {
35+ CLLocation *newLocation = [[CLLocation alloc ] initWithLatitude: latitude longitude: longitude];
36+ [MParticle sharedInstance ].location = newLocation;
37+ }
38+
3339RCT_EXPORT_METHOD (setUploadInterval:(NSInteger )uploadInterval)
3440{
3541 [[MParticle sharedInstance ] setUploadInterval: uploadInterval];
Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ const getSession = (completion) => {
158158 NativeModules . MParticle . getSession ( completion )
159159}
160160
161+ const setLocation = ( latitude , longitude ) => {
162+ NativeModules . MParticle . setLocation ( latitude , longitude )
163+ }
164+
161165// ******** Identity ********
162166class User {
163167 constructor ( userId ) {
@@ -686,7 +690,8 @@ const MParticle = {
686690 isKitActive,
687691 getAttributions,
688692 logPushRegistration,
689- getSession
693+ getSession,
694+ setLocation
690695}
691696
692697export default MParticle
You can’t perform that action at this time.
0 commit comments