Skip to content

Commit

Permalink
Merge pull request #1353 from OneSignal/add-setLaunchURLsInApp
Browse files Browse the repository at this point in the history
Add `setLaunchURLsInApp` function
  • Loading branch information
rgomezp authored Jan 31, 2022
2 parents d256777 + 4c6952a commit fb575cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {

// api is used instead of implementation so the parent :app project can access any of the OneSignal Java
// classes if needed. Such as com.onesignal.NotificationExtenderService
api 'com.onesignal:OneSignal:4.6.5'
api 'com.onesignal:OneSignal:4.6.6'

testImplementation 'junit:junit:4.12'
}
Expand Down
4 changes: 4 additions & 0 deletions ios/RCTOneSignal/RCTOneSignalEventEmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
}];
}

RCT_EXPORT_METHOD(setLaunchURLsInApp:(BOOL)isEnabled) {
[OneSignal setLaunchURLsInApp:isEnabled];
}

RCT_EXPORT_METHOD(setLogLevel:(int)logLevel visualLogLevel:(int)visualLogLevel) {
[OneSignal setLogLevel:logLevel visualLevel:visualLogLevel];
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-onesignal",
"version": "4.3.5",
"version": "4.3.6",
"description": "React Native OneSignal SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,21 @@ export default class OneSignal {
}
}

/**
* This method can be used to set if launch URLs should be opened in safari or within the application.
* @param {boolean} isEnabled
* @returns
*/
static setLaunchURLsInApp(isEnabled: boolean): void {
if (!isNativeModuleLoaded(RNOneSignal)) return;

if (Platform.OS === 'ios') {
RNOneSignal.setLaunchURLsInApp(isEnabled);
} else {
console.log("setLaunchURLsInApp: this function is not supported on Android");
}
}

/* E X T E R N A L U S E R I D */

/**
Expand Down

0 comments on commit fb575cf

Please sign in to comment.