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> {
103
103
await OneSignal .shared
104
104
.setAppId ("380dc082-5231-4cc2-ab51-a03da5a0e4c2" );
105
105
106
+ // iOS-only method to open launch URLs in Safari when set to false
107
+ OneSignal .shared.setLaunchURLsInApp (false );
108
+
106
109
bool requiresConsent = await OneSignal .shared.requiresUserPrivacyConsent ();
107
110
108
111
this .setState (() {
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
125
125
[self disablePush: call withResult: result];
126
126
else if ([@" OneSignal#postNotification" isEqualToString: call.method])
127
127
[self postNotification: call withResult: result];
128
+ else if ([@" OneSignal#setLaunchURLsInApp" isEqualToString: call.method])
129
+ [self setLaunchURLsInApp: call withResult: result];
128
130
else if ([@" OneSignal#promptLocation" isEqualToString: call.method])
129
131
[self promptLocation: call withResult: result];
130
132
else if ([@" OneSignal#setLocationShared" isEqualToString: call.method])
@@ -244,6 +246,12 @@ - (void)postNotification:(FlutterMethodCall *)call withResult:(FlutterResult)res
244
246
}];
245
247
}
246
248
249
+ - (void )setLaunchURLsInApp : (FlutterMethodCall *)call withResult : (FlutterResult)result {
250
+ BOOL isEnabled = [call.arguments[@" isEnabled" ] boolValue ];
251
+ [OneSignal setLaunchURLsInApp: isEnabled];
252
+ result (nil );
253
+ }
254
+
247
255
- (void )promptLocation : (FlutterMethodCall *)call withResult : (FlutterResult)result {
248
256
[OneSignal promptLocation ];
249
257
result (nil );
Original file line number Diff line number Diff line change 1
1
import 'dart:async' ;
2
+ import 'dart:io' show Platform;
2
3
import 'package:flutter/services.dart' ;
3
4
import 'package:onesignal_flutter/src/permission.dart' ;
4
5
import 'package:onesignal_flutter/src/subscription.dart' ;
@@ -164,6 +165,19 @@ class OneSignal {
164
165
{'notificationId' : notificationId, 'shouldDisplay' : shouldDisplay});
165
166
}
166
167
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
+
167
181
/// Allows you to completely disable the SDK until your app calls the
168
182
/// OneSignal.consentGranted(true) function. This is useful if you want
169
183
/// to show a Terms and Conditions or privacy popup for GDPR.
You can’t perform that action at this time.
0 commit comments