Skip to content

Commit 30045d0

Browse files
committed
Fix Incorrect Context
• The OneSignalPlugin was initializing the native OneSignal SDK with an incorrect context. Switched to using the flutter registrar's activeContext instead. • This would have caused the SDK to always believe that the app was not currently in focus, meaning the SDK would ignore the current inFocusDisplayType option and always show notifications as normal Android notifications
1 parent 2c6fcd2 commit 30045d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ else if (call.method.contentEquals("OneSignal#didSetNotificationOpenedHandler"))
9898

9999
private void initOneSignal(MethodCall call, Result result) {
100100
String appId = call.argument("appId");
101-
Context context = flutterRegistrar.context();
101+
Context context = flutterRegistrar.activeContext();
102102

103103
OneSignal.Builder builder = OneSignal.getCurrentOrNewInitBuilder();
104104
builder.unsubscribeWhenNotificationsAreDisabled(true);
@@ -164,8 +164,8 @@ private void getPermissionSubscriptionState(Result result) {
164164
}
165165

166166
private void setInFocusDisplayType(MethodCall call, Result result) {
167-
int deplayType = call.argument("displayType");
168-
OneSignal.setInFocusDisplaying(deplayType);
167+
int displayType = call.argument("displayType");
168+
OneSignal.setInFocusDisplaying(displayType);
169169
result.success(null);
170170
}
171171

0 commit comments

Comments
 (0)