feat: [SDK-4768] support disabling location module#29
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
18 tasks
|
@claude review |
|
@claude review once |
nan-li
approved these changes
Jun 10, 2026
sherwinski
reviewed
Jun 11, 2026
Comment on lines
+650
to
+654
| try { | ||
| OneSignal.Location.requestPermission() | ||
| } catch (t: Throwable) { | ||
| logLocationModuleNotAvailable(t) | ||
| } |
There was a problem hiding this comment.
If the scope is cancelled while OneSignal.Location.requestPermission() is suspended, the new catch (t: Throwable):
- catches the
CancellationExceptioninstead of letting cancellation propagate, - logs a misleading "location module is not available" error,
- then calls
call.resolve()on the destroyed bridge — the exact crash path the previous fix removed.
Fix: rethrow cancellation before the broad catch:
try {
OneSignal.Location.requestPermission()
} catch (e: CancellationException) {
throw e
} catch (t: Throwable) {
logLocationModuleNotAvailable(t)
}
sherwinski
reviewed
Jun 11, 2026
There was a problem hiding this comment.
Each try/catch in this file also throws when the SDK isn't initialized yet, which can be confusing to debug. Consider a message like "OneSignal.Location call failed — the location module may not be included in this build" or detecting the module-missing case specifically.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Adds
ONESIGNAL_DISABLE_LOCATIONsupport so Capacitor apps can exclude the native OneSignal location module from Android and iOS builds.Details
Motivation
Apps that do not use
OneSignal.Locationshould be able to remove the native location module, matching the Flutter SDK behavior and reducing unnecessary native dependency surface.Scope
This PR updates Android Gradle, CocoaPods, and SwiftPM dependency resolution to omit location when
ONESIGNAL_DISABLE_LOCATION=trueor1is set. It keeps the JavaScript API stable and makes Android location bridge calls no-op safely when the location module is missing.Testing
Unit testing
Existing TypeScript bridge tests were run; no new unit tests were added because the public TypeScript API is unchanged and the behavior is native dependency-resolution/runtime fallback logic.
Manual testing
bun run lintbun run testbun run buildONESIGNAL_DISABLE_LOCATION=trueAndroid dependency resolution confirmed modularcore,notifications, andin-app-messagesartifactsONESIGNAL_DISABLE_LOCATION=true ./gradlew :onesignal-capacitor-plugin:compileDebugKotlinONESIGNAL_DISABLE_LOCATION=true swift package describe --type jsonconfirmedOneSignalLocationis omittedONESIGNAL_DISABLE_LOCATION=true pod ipc spec OneSignalCapacitorPlugin.podspecconfirmed location-free CocoaPods subspecsAffected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor