File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,9 @@ class _MyAppState extends State<MyApp> {
103103 await OneSignal .shared
104104 .setAppId ("380dc082-5231-4cc2-ab51-a03da5a0e4c2" );
105105
106+ // iOS-only method to open launch URLs in Safari when set to false
107+ OneSignal .shared.setLaunchURLsInApp (false );
108+
106109 bool requiresConsent = await OneSignal .shared.requiresUserPrivacyConsent ();
107110
108111 this .setState (() {
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
125125 [self disablePush: call withResult: result];
126126 else if ([@" OneSignal#postNotification" isEqualToString: call.method])
127127 [self postNotification: call withResult: result];
128+ else if ([@" OneSignal#setLaunchURLsInApp" isEqualToString: call.method])
129+ [self setLaunchURLsInApp: call withResult: result];
128130 else if ([@" OneSignal#promptLocation" isEqualToString: call.method])
129131 [self promptLocation: call withResult: result];
130132 else if ([@" OneSignal#setLocationShared" isEqualToString: call.method])
@@ -244,6 +246,12 @@ - (void)postNotification:(FlutterMethodCall *)call withResult:(FlutterResult)res
244246 }];
245247}
246248
249+ - (void )setLaunchURLsInApp : (FlutterMethodCall *)call withResult : (FlutterResult)result {
250+ BOOL isEnabled = [call.arguments[@" isEnabled" ] boolValue ];
251+ [OneSignal setLaunchURLsInApp: isEnabled];
252+ result (nil );
253+ }
254+
247255- (void )promptLocation : (FlutterMethodCall *)call withResult : (FlutterResult)result {
248256 [OneSignal promptLocation ];
249257 result (nil );
Original file line number Diff line number Diff line change 11import 'dart:async' ;
2+ import 'dart:io' show Platform;
23import 'package:flutter/services.dart' ;
34import 'package:onesignal_flutter/src/permission.dart' ;
45import 'package:onesignal_flutter/src/subscription.dart' ;
@@ -164,6 +165,19 @@ class OneSignal {
164165 {'notificationId' : notificationId, 'shouldDisplay' : shouldDisplay});
165166 }
166167
168+ /// Only applies to iOS
169+ /// Sets if launch URLs should be opened within the application or in Safari.
170+ /// When set to true, launch URLs will open an in-app browser.
171+ Future <void > setLaunchURLsInApp (bool isEnabled) async {
172+ if (Platform .isIOS) {
173+ await _channel.invokeMethod (
174+ "OneSignal#setLaunchURLsInApp" , {'isEnabled' : isEnabled});
175+ } else {
176+ _onesignalLog (OSLogLevel .info,
177+ "setLaunchURLsInApp: this function is not supported on Android" );
178+ }
179+ }
180+
167181 /// Allows you to completely disable the SDK until your app calls the
168182 /// OneSignal.consentGranted(true) function. This is useful if you want
169183 /// to show a Terms and Conditions or privacy popup for GDPR.
You can’t perform that action at this time.
0 commit comments