On IOS
OneSignal.initWithLaunchOptions(launchOptions,
appId: Config.OneSignal.APPID,
handleNotificationAction: notificationOpenedBlock,
settings: onesignalInitSettings)
OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification;
OneSignal.setLocationShared(false)
But Lat/long still up to 1signal
You can try changing your app's permission configuration in your plist file. If you still need help, please contact us through our support channel at OneSignal.com
Hello,
I would like to add some information.
SDK version is : 2.11.0
Init code is :
>
let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false] OneSignal.initWithLaunchOptions(launchOptions, appId: Config.OneSignal.APPID, handleNotificationAction: notificationOpenedBlock, settings: onesignalInitSettings) OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification OneSignal.setLocationShared(false)
When the app is clean-installed on the device then started :
We ask for notifications -> Answer "YES"
We ask for location permission -> Answer "Always" or "When in use"
The location data is send to OneSignal dashboard, but it shouldn't because of OneSignal.setLocationShared(false)
It seems that setLocationShared(false) does nothing, even if the documentation says
To disable location tracking in our SDK, you can call the setLocationShared(false) method of our SDK's
Have you tried putting the call before the initialization call?
Yes, I've tried all combinations with the setLocationShared call before and after init call, and with "Always" and "When app in use" authorization. The location is always sent.
@aboudou ,
Have you tried to change your plist file?
@rgomezp what do you mean exactly ?
The following keys are defined in the plist file :
NSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescriptionand UIBackgroundModes with location
I meant you can try to remove those keys. However, I assume this is an issue because you need those permissions elsewhere. Correct me if I'm wrong
I was able to reproduce the issue if the setLocationShared(false) is called after the initWithLaunchOptions. However, the issue did not appear when I moved the call before the init...
OneSignal.setLocationShared(false)
OneSignal.initWithLaunchOptions(launchOptions,
appId: "ab8ja948-387a-44bc-a185-e26675ecz55y",
handleNotificationAction: nil,
settings: onesignalInitSettings)
Edit: you can see this clearly by using the API "edit device" endpoint to clear the lat and long values for the player before re-building the app
About the keys : yes, wee need the permissions elsewhere.
About location info. Each time I test, I remove the OneSignal player from the dashboard, and the app from the device.
With setLocationShared(false) before the initWithLaunchOptions:
@rgomezp Could you please fix it because it is very bad for our compliance with the GDPR.
I cannot reproduce this issue, unfortunately. Would any of you be willing to share a project with us that reproduces the issue? You can reach out through our support channel at OneSignal.com
I'll try to make a project trying to reproduce this issue on monday.
Hello @rgomezp,
I've just tried my code against iOS SDK 13.0 (was against iOS SDK 12.4 before). Now i have the same behavior than yours :
setLocationShared(false) is before initWithLaunchOptions, the location point is not setsetLocationShared(false) is after initWithLaunchOptions, the location point is setYou may have a bug with iOS SDK 12.x, where location point where always set. Nevertheless, if setLocationShared(false) has to be set before initWithLaunchOptions, I suppose it should be put in the SDK documentation.
@rgomezp I have more informations after some additionnal tests.
(Case 1) If I remove the app from the device, remove the player from OneSignal dashboard :
(Case 2) Then I let the app on the device, but I remove the player :
I tried to dig deeper within (Case 1), and found this :
OneSignal.promptLocation(), triggering the alertview for location permission, the player is created, and the location point is not setHi,
Thanks for the info. It's possible there's a bug in iOS SDK 12, though if it works in 13 we most likely won't address the issue in the old version since most devices will be on iOS 13 soon.
For the second case, what happens if you close the app and then re-open it?
Both cases where done with SDK 13.
For the second case, I've just seen that location point was set between my previous message and this one. It seems there is some delay in some cases.
So, I refined my testings :
I delete the app
I delete OneSignal player
I install and starthe app
I grant access to notifications and location
=> Player is created with location point set
I force kill the app
I delete OneSignal player
I start the app again
=> Player created without location point
I send the app to the background
I bring it back to the foreground
=> No location point is set
I send the app to the background
Starting here, I'll monitor the dashboard from time to time to check if location point is set
@rgomezp Same issue SDK IOS 13
This will be fixed in the next release 2.11.1.
Needed to return early in the callback for LocationPrompt when user clicks Allow and setLocationShared(false).
Thanks :)
@mikechoch I've just tried with 2.11.1, and I have the same behavior. The location is still send.
As I can't see any commit above this bug in master branch, I suppose it's not in this release yet ?
Multiple reports this is still happening
The fix is in this PR:
https://github.com/OneSignal/OneSignal-iOS-SDK/pull/539
In this commit:
https://github.com/OneSignal/OneSignal-iOS-SDK/commit/f3ecc0afe8ce3a3d8f2d213bc8cdbd6af2b3ee09
This has been tested and is not reproducible and the fix was released in 2.11.1.
We default location sharing to true in our SDK, so you should set location shared to false ASAP. Otherwise if you Allow location services and location shared is not already false, the location point will definitely be sent in the player register or player update request.
Right now there is no way to clear out location point in the dashboard for the players, so once the point is sent it will stay there until a new point replaces it.
UPDATE:
As an update some more handling and checking has been implemented for better VERBOSE logging and control over last location. Now when using setLocationShared:false the last location is cleared instantly.
You can see this in PR:
https://github.com/OneSignal/OneSignal-iOS-SDK/pull/602
In this commit:
https://github.com/OneSignal/OneSignal-iOS-SDK/pull/602/commits/f4362677e1869619ddfa36dfe301ee0523f42edd
I'm still seeing iOS devices get a location set in the OneSignal dashboard when I call setLocationShared(false) before initializing OneSignal. I'm using the latest version of the OneSignal Cordova plugin (2.8.2).
See here for details.
Maybe I'm misunderstanding what setLocationShared(false) should do? I'd expect it to not send location data to OneSignal if set to false, even if the user granted my app location permissions.
If the user initially denies my app location permissions, I see OneSignal logging that it shouldn't send location:
2020-01-20 12:37:50.180889-0500 APP NAME[2511:899027] VERBOSE: Not sending location with 'on_session' request payload, setLocationShared is false or lastLocation is null
If I then go to Settings and grant the app location permissions, when I load the app again, OneSignal immediately gets the location and sends it.
Here is OneSignal debug of the app going into the background, grabbing location and sending it once the app comes back into the foreground:
```2020-01-20 12:40:37.939642-0500 APP NAME[2511:898457] VERBOSE: oneSignalApplicationWillResignActive
2020-01-20 12:40:37.940083-0500 APP NAME[2511:898457] VERBOSE: Application Backgrounded started
2020-01-20 12:40:37.947780-0500 APP NAME[2511:898457] VERBOSE: TimeProcessor
2020-01-20 12:40:37.948319-0500 APP NAME[2511:898457] VERBOSE: sendOnFocusCall unattributed with totalTimeActive 167.946044
2020-01-20 12:40:37.948485-0500 APP NAME[2511:898457] VERBOSE: OSBaseFocusTimeProcessor hasMinSyncTime getMinSessionTime: 60 activeTime: 167.946044
2020-01-20 12:40:37.961911-0500 APP NAME[2511:899348] VERBOSE: beginBackgroundFocusTask start
2020-01-20 12:40:37.965155-0500 APP NAME[2511:899348] VERBOSE: HTTP Request (OSRequestOnFocus) with URL: https://onesignal.com/api/v1/players/PLAYER_ID/on_focus, with parameters: {
"net_type" : 0,
"active_time" : 167.94604396820068,
"state" : "ping",
"app_id" : "APP_ID",
"type" : 1,
"device_type" : 0
}
2020-01-20 12:40:38.129344-0500 APP NAME[2511:899373] VERBOSE: network response (OSRequestOnFocus): {
id = "PLAYER_ID";
success = 1;
}
2020-01-20 12:40:38.129730-0500 APP NAME[2511:899373] Request
id = "PLAYER_ID";
success = 1;
}
2020-01-20 12:40:38.132311-0500 APP NAME[2511:898457] VERBOSE: sendOnFocusCallWithParams unattributed succeed, saveUnsentActiveTime with 0
2020-01-20 12:40:38.132505-0500 APP NAME[2511:898457] VERBOSE: OSUnattributedFocusTimeProcessor:endDelayBackgroundTask:2
2020-01-20 12:40:38.132648-0500 APP NAME[2511:898457] VERBOSE: endBackgroundFocusTask called
2020-01-20 12:40:38.444208-0500 APP NAME[2511:898457] VERBOSE: oneSignalApplicationDidEnterBackground
2020-01-20 12:40:38.455949-0500 APP NAME[2511:898457] ERROR: CLLocationManager did fail with error: Error Domain=kCLErrorDomain Code=1 "(null)"
2020-01-20 12:40:38.636680-0500 APP NAME[2511:898457] [Snapshotting] Snapshotting a view (0x103046a00, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
2020-01-20 12:40:48.417419-0500 APP NAME[2511:898457] ERROR: CLLocationManager did fail with error: Error Domain=kCLErrorDomain Code=1 "(null)"
2020-01-20 12:41:03.991678-0500 APP NAME[2511:899373] VERBOSE: HTTP Request (OSRequestSendLocation) with URL: https://onesignal.com/api/v1/players/PLAYER_ID, with parameters: {
"app_id" : "APP_ID",
"loc_bg" : true,
"loc_acc_vert" : 10,
"lat" : MY_LAT,
"net_type" : 0,
"loc_acc" : 65,
"long" : MY_LONG
}
2020-01-20 12:41:04.585394-0500 APP NAME[2511:899666] VERBOSE: network response (OSRequestSendLocation): {
success = 1;
}
2020-01-20 12:41:04.587319-0500 APP NAME[2511:899666] Request
success = 1;
}
2020-01-20 12:41:11.684391-0500 APP NAME[2511:898457] VERBOSE: oneSignalApplicationDidBecomeActive
2020-01-20 12:41:11.684869-0500 APP NAME[2511:898457] VERBOSE: Application Foregrounded started
2020-01-20 12:41:11.685188-0500 APP NAME[2511:898457] VERBOSE: cancelFocusCall of {
"NOT_ATTRIBUTED" = "
}
2020-01-20 12:41:11.686654-0500 APP NAME[2511:898457] DEBUG: shouldRegisterNow: lastTimeClosed: 1579542037.940196
2020-01-20 12:41:11.698182-0500 APP NAME[2511:899387] DEBUG: shouldRegisterNow: lastTimeClosed: 1579542037.940196
2020-01-20 12:41:11.698332-0500 APP NAME[2511:899387] VERBOSE: Session is restarting
2020-01-20 12:41:11.706580-0500 APP NAME[2511:899387] VERBOSE: OSSession changed
from:
session: UNATTRIBUTED
, directNotificationId: (null)
, indirectNotificationIds: (null)
to:
session: UNATTRIBUTED
, directNotificationId: (null)
, indirectNotificationIds: (null)
2020-01-20 12:41:11.725682-0500 APP NAME[2511:899387] VERBOSE: onSessionEnded started
2020-01-20 12:41:11.729006-0500 APP NAME[2511:899387] VERBOSE: TimeProcessor
2020-01-20 12:41:11.729226-0500 APP NAME[2511:899387] VERBOSE: sendOnFocusCall unattributed with totalTimeActive -1.000000
2020-01-20 12:41:11.729334-0500 APP NAME[2511:899387] VERBOSE: OSBaseFocusTimeProcessor hasMinSyncTime getMinSessionTime: 60 activeTime: -1.000000
2020-01-20 12:41:11.729424-0500 APP NAME[2511:899387] VERBOSE: unattributed session saveUnsentActiveTime -1.000000
2020-01-20 12:41:11.737349-0500 APP NAME[2511:899387] VERBOSE: getNotificationTypes:mSubscriptionStatus: -1
2020-01-20 12:41:11.751231-0500 APP NAME[2511:899387] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor:
2020-01-20 12:41:11.752165-0500 APP NAME[2511:899387] DEBUG: provision: {
PROVISION DATA HERE
}
2020-01-20 12:41:11.762281-0500 APP NAME[2511:899387] VERBOSE: Calling OneSignal create/on_session
2020-01-20 12:41:11.762445-0500 APP NAME[2511:899387] VERBOSE: Attaching device location to 'on_session' request payload
2020-01-20 12:41:11.763678-0500 APP NAME[2511:899714] VERBOSE: HTTP Request (OSRequestRegisterUser) with URL: https://onesignal.com/api/v1/players/PLAYER_ID/on_session, with parameters: {
"app_id" : "APP_ID",
"net_type" : 0,
"test_type" : 1,
"loc_acc_vert" : 10,
"loc_acc" : 65,
"long" : MY_LONG,
"device_type" : 0,
"sdk" : "021205",
"lat" : MY_LAT,
"identifier" : "ID",
"language" : "en-US",
"device_os" : "12.4.1",
"game_version" : "55",
"timezone" : -18000,
"ad_id" : "AD_ID",
"notification_types" : 31,
"carrier" : "Verizon",
"device_model" : "iPad5,2"
}
2020-01-20 12:41:11.934211-0500 APP NAME[2511:899387] VERBOSE: network response (OSRequestRegisterUser): {
id = "PLAYER_ID";
success = 1;
}
2020-01-20 12:41:11.934498-0500 APP NAME[2511:899387] Request
id = "PLAYER_ID";
success = 1;
}
2020-01-20 12:41:11.935093-0500 APP NAME[2511:898457] VERBOSE: on_session result: {
push = {
id = "PLAYER_ID";
success = 1;
};
}
2020-01-20 12:41:11.936220-0500 APP NAME[2511:898457] VERBOSE: getNotificationTypes:mSubscriptionStatus: -1
2020-01-20 12:41:11.938602-0500 APP NAME[2511:898457] VERBOSE: getNotificationTypes:mSubscriptionStatus: -1
```
When I have some time I'll try to create a complete sample project that demonstrates the issue.
You can find a sample app to reproduce the issue here: https://github.com/ndrake/onesignal-test
Thanks for your patience while we reproduce
Howdy,
This issue should now be resolved.
Enjoy!
Hi,
Sorry to report this is still happening with version 2.9.0 of the Cordova plugin (iOS SDK version 2.13.1).
It looks like the player creation is working correctly now, lat/lon are not being sent:
2020-04-24 18:19:14.388324-0400 MyApp[527:39694] VERBOSE: Calling OneSignal create/on_session
2020-04-24 18:19:14.388482-0400 MyApp[527:39694] VERBOSE: Not sending location with 'on_session' request payload, setLocationShared is false or lastLocation is null
2020-04-24 18:19:14.389113-0400 MyApp[527:39695] VERBOSE: HTTP Request (OSRequestRegisterUser) with URL: https://api.onesignal.com/players, with parameters: {
"app_id" : "REDACTED",
"net_type" : 0,
"test_type" : 1,
"ios_bundle" : "REDACTED",
"device_type" : 0,
"sdk_type" : "cordova",
"sdk" : "021301",
"identifier" : "REDACTED",
"language" : "en-US",
"device_os" : "13.3.1",
"game_version" : "0.0.1",
"timezone" : -14400,
"ad_id" : "REDACTED",
"notification_types" : 31,
"device_model" : "iPod9,1"
}
But shortly after that I see this:
2020-04-24 18:19:15.259317-0400 MyApp[527:39459] DEBUG: OneSignalLocation sendAndClearLocationListener listeners: (
)
2020-04-24 18:19:15.306891-0400 MyApp[527:39459] DEBUG: OneSignalLocation sendAndClearLocationListener listeners: (
)
2020-04-24 18:19:15.308010-0400 MyApp[527:39690] VERBOSE: HTTP Request (OSRequestSendLocation) with URL: https://api.onesignal.com/players/REDACTED, with parameters: {
"app_id" : "REDACTED",
"loc_bg" : false,
"loc_acc_vert" : 10,
"lat" : REDACTED,
"net_type" : 0,
"loc_acc" : 65,
"long" : REDACTED
}
2020-04-24 18:19:15.820519-0400 MyApp[527:39695] VERBOSE: network response (OSRequestSendLocation): {
success = 1;
}
2020-04-24 18:19:15.821299-0400 MyApp[527:39695] Request <OSRequestSendLocation: 0x28177d6e0> success result {
success = 1;
}
I've attached the complete console output. I used my test App to reproduce this issue: https://github.com/ndrake/onesignal-test
Thanks!
Nate
onesig-ios-location-bug-log.txt
Ping @rgomezp
@ndrake This was a OneSignal Cordova SDK issue and has been fixed in PR 667