Skip to content

Commit c07b64f

Browse files
committed
Add Android Initialization Parameters
• Adds the SDK type and also enables GCM receiver filtering and enables the 'unsubscribe when notifications are disabled' option
1 parent 32c9dcf commit c07b64f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class OneSignalPlugin implements MethodCallHandler, NotificationReceivedH
4040

4141
public static void registerWith(Registrar registrar) {
4242

43+
OneSignal.sdkType = "flutter";
44+
4345
OneSignalPlugin plugin = new OneSignalPlugin();
4446

4547
plugin.waitingForUserPrivacyConsent = false;
@@ -94,13 +96,18 @@ public void initOneSignal(MethodCall call, Result result) {
9496
Map<String, Object> args = (Map<String, Object>)call.arguments;
9597
Context context = flutterRegistrar.context();
9698

99+
OneSignal.Builder builder = OneSignal.getCurrentOrNewInitBuilder();
100+
builder.unsubscribeWhenNotificationsAreDisabled(true);
101+
builder.filterOtherGCMReceivers(true);
97102
OneSignal.init(context, null, (String)args.get("appId"), this, this);
98103

99104
if (didSetRequiresPrivacyConsent) {
100105
this.waitingForUserPrivacyConsent = true;
101106
} else {
102107
this.addObservers();
103108
}
109+
110+
result.success(null);
104111
}
105112

106113
public void addObservers() {

0 commit comments

Comments
 (0)