Repository navigation
fix: [SDK-5698] let initialize and login reach native #2017
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import { | |
| isNativeModuleLoaded, | ||
| isFunction, | ||
| isMissing, | ||
| isNotStringOrNullish, | ||
| isObject, | ||
| isObjectSerializable, | ||
| isValidCallback, | ||
|
|
@@ -137,7 +138,7 @@ export namespace OneSignal { | |
| /** Initializes the OneSignal SDK. This should be called during startup of the application. */ | ||
| export function initialize(appId: string) { | ||
| if (!isNativeModuleLoaded(RNOneSignal)) return; | ||
| if (isMissing(appId, 'initialize: appId')) return; | ||
| if (isNotStringOrNullish(appId, 'initialize: appId')) return; | ||
|
|
||
| RNOneSignal.initialize(appId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: on Android, Could we only latch when appId is non-empty, or just let the SDK's own already-initialized check handle repeat calls?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, and you are right that It sits behind a bigger blocker I had wrong: this needs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now fixed in 217ae1c. |
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: when native ignores init (null appId and nothing cached), the startup reads below still run, so the user sees "failed to read initial state" instead of the real problem.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. The startup read failure would mask the real cause. |
||
|
|
@@ -152,7 +153,7 @@ export namespace OneSignal { | |
| */ | ||
| export function login(externalId: string) { | ||
| if (!isNativeModuleLoaded(RNOneSignal)) return; | ||
| if (isMissing(externalId, 'login: externalId')) return; | ||
| if (isNotStringOrNullish(externalId, 'login: externalId')) return; | ||
|
|
||
| RNOneSignal.login(externalId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: removing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now fixed in 217ae1c. Added |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: null is now an intended input here, but the Spec (
NativeOneSignal.ts:8) still typesappId: string, and the iOS bridge (RCTOneSignalEventEmitter.mm:136) still marks it_Nonnull. It works at runtime since TurboModules pass nil through, butstring | nulland_Nullablewould match the behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
string | nullon the Spec and_Nullableon the bridge would match the intent. Not done yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Half done in 217ae1c: the iOS bridge parameter is
_Nullablenow.Left the Spec as
appId: string. Changing it means codegen plus a native build to verify, and CI here is JS-only, so I would be pushing an unverified codegen change. Happy to do it if you want it in this PR.