Skip to content

Commit e5448c1

Browse files
committed
Adds check to new major version functions to prevent Expo crashes
Motivation: in Expo environments, the `RNOneSignal` object is not loaded correctly, leading to crashes to functions that don't have this check.
1 parent 15bea57 commit e5448c1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class OneSignal {
2424
* @param {string} appId
2525
*/
2626
static setAppId(appId) {
27+
if (!isObjectNonNull(RNOneSignal)) return;
2728
RNOneSignal.setAppId(appId);
2829
}
2930

@@ -444,6 +445,7 @@ export default class OneSignal {
444445
}
445446

446447
static clearHandlers() {
448+
if (!isObjectNonNull(RNOneSignal)) return;
447449
eventManager.clearHandlers();
448450
}
449451
}

0 commit comments

Comments
 (0)