Skip to content

Commit d28928d

Browse files
committed
Added setLocationShared method
1 parent 01620f6 commit d28928d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

iOS_SDK/OneSignal/OneSignal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
274274

275275
// - Request and track user's location
276276
+ (void)promptLocation;
277+
+ (void)setLocationShared:(BOOL)enable;
277278

278279
// - Sends the MD5 and SHA1 of the provided email
279280
// Optional method that sends us the user's email as an anonymized hash so that we can better target and personalize notifications sent to that user across their devices.

iOS_SDK/OneSignal/OneSignal.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ @implementation OneSignal
9696
OSIdsAvailableBlock idsAvailableBlockWhenReady;
9797
BOOL disableBadgeClearing = NO;
9898
BOOL mSubscriptionSet;
99+
BOOL mShareLocation = YES;
99100

100101
+ (NSString*)app_id {
101102
return app_id;
@@ -138,7 +139,9 @@ + (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
138139
if ([@"b2f7f966-d8cc-11eg-bed1-df8f05be55ba" isEqualToString:appId] || [@"5eb5a37e-b458-11e3-ac11-000c2940e62c" isEqualToString:appId])
139140
onesignal_Log(ONE_S_LL_WARN, @"OneSignal Example AppID detected, please update to your app's id found on OneSignal.com");
140141

141-
[OneSignalLocation getLocation:false];
142+
if (mShareLocation) {
143+
[OneSignalLocation getLocation:false];
144+
}
142145

143146
if (self) {
144147

@@ -519,6 +522,11 @@ + (void)setSubscription:(BOOL)enable {
519522
[OneSignal sendNotificationTypesUpdate:false];
520523
}
521524

525+
526+
+ (void)setLocationShared:(BOOL)enable {
527+
mShareLocation = enable;
528+
}
529+
522530
+ (void) promptLocation {
523531
[OneSignalLocation getLocation:true];
524532
}
@@ -695,7 +703,7 @@ + (void)registerUser {
695703
NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil];
696704
[request setHTTPBody:postData];
697705

698-
if ([OneSignalLocation lastLocation]) {
706+
if (mShareLocation && [OneSignalLocation lastLocation]) {
699707
dataDic[@"lat"] = [NSNumber numberWithDouble:[OneSignalLocation lastLocation]->cords.latitude];
700708
dataDic[@"long"] = [NSNumber numberWithDouble:[OneSignalLocation lastLocation]->cords.longitude];
701709
dataDic[@"loc_acc_vert"] = [NSNumber numberWithDouble:[OneSignalLocation lastLocation]->verticalAccuracy];

0 commit comments

Comments
 (0)