Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OneSignal to app without transitively linking against CoreLocation #1536

Open
hakonk opened this issue Jan 17, 2025 · 4 comments
Open

Add OneSignal to app without transitively linking against CoreLocation #1536

hakonk opened this issue Jan 17, 2025 · 4 comments

Comments

@hakonk
Copy link

hakonk commented Jan 17, 2025

It seems that the default behavior of OneSignal is to link against its OneSignalLocation, which in turn imports CoreLocation. This means that, even if the said code path is never reached, Apple will prompt you with a warning when submitting the app to the App Store if the NSLocationWhenInUseUsageDescription is not in the app's Info.plist.

This is, in my opinion, unfortunate as one would have to come up with a reason for NSLocationWhenInUseUsageDescription even if the feature will never be used. Judging from the code in OneSignalLocationManager, the dynamic features of the Objective-C runtime are heavily employed, which leads me to believe one has tried to use CoreLocation without employing the types exposed via the framework's interface. That is, in a way where CoreLocation is possibly linked, but not necessarily. This leads me to believe an attempt to make use of CoreLocation only for certain conditions when it is linked has been made, possibly to for occasions where the app programmer does not want to link against CoreLocation and manage the privacy implications. CoreLocation is however imported unconditionally.

As location services for push notifications are not strictly needed, I believe the cleanest approach would be to conditionally link against OneSignalLocation only if such features are necessary for the app consuming the OneSignal SDK. That is, the app programmer explicitly adds OneSignalLocation to the Podfile as a dependency when this functionality is needed.

Are my assumptions correct? Please advise me if I have missed anything related to how to disable CoreLocation for OneSignal. For the record, I'm using the Expo plugin for React Native to add OneSignal as a dependency.

@nan-li
Copy link
Contributor

nan-li commented Jan 17, 2025

Hi @hakonk, this is known to us. You are right, we did try to use the dynamic features of Objc to avoid this location detection by Apple. We have since ripped out OneSignalLocation from the native iOS SDK so clients can add the dependencies like this

target 'your_project_name' do
  pod 'OneSignal/OneSignal', '>= 5.0.0', '< 6.0'
  pod 'OneSignal/OneSignalInAppMessages', '>= 5.0.0', '< 6.0'
  # If your app does not use CoreLocation, you can remove this:
  pod 'OneSignal/OneSignalLocation', '>= 5.0.0', '< 6.0'
  # Your other pods here
end

However, this is only available to clients using the native SDK directly - we do not have this available to cross-platform SDKs who import all the features at once.

@hakonk
Copy link
Author

hakonk commented Jan 17, 2025

Thanks for answering! Alright, I see. So I guess the config plugin for expo can be tweaked in order to only add certain additional features?

@nan-li
Copy link
Contributor

nan-li commented Jan 18, 2025

This would be considered a new feature we would investigate how best to support, as on react native now it is a single import via something like yarn add react-native-onesignal.

@hakonk
Copy link
Author

hakonk commented Jan 20, 2025

I see. Is that something you have discussed doing as well or should I submit a feature request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants