Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: OneSignal/OneSignal-Flutter-SDK
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.1.3
Choose a base ref
...
head repository: OneSignal/OneSignal-Flutter-SDK
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Apr 10, 2024

  1. bump version numbers to 5.1.4

    Bump native SDKs to iOS 5.1.4 and Android 5.1.8
    emawby committed Apr 10, 2024
    Copy the full SHA
    6f75e05 View commit details
  2. Merge pull request #871 from OneSignal/release-5.1.4

    Release 5.1.4
    emawby authored Apr 10, 2024
    Copy the full SHA
    6cf538c View commit details

Commits on Apr 12, 2024

  1. Copy the full SHA
    7390fea View commit details
  2. Merge pull request #873 from OneSignal/add_migration_advisory_to_readme

    Add migration advisory to readme and migration guide
    jennantilla authored Apr 12, 2024
    Copy the full SHA
    e2c003e View commit details

Commits on Apr 16, 2024

  1. release commit 5.1.5

    nan-li committed Apr 16, 2024
    Copy the full SHA
    e4213d7 View commit details
  2. Merge pull request #875 from OneSignal/rel/5.1.5

    Release 5.1.5
    nan-li authored Apr 16, 2024
    Copy the full SHA
    6c88254 View commit details

Commits on Apr 30, 2024

  1. Copy the full SHA
    a1e66bc View commit details

Commits on May 1, 2024

  1. release commit 5.1.6

    jennantilla committed May 1, 2024
    Copy the full SHA
    7c31687 View commit details
  2. Merge pull request #882 from OneSignal/rel/5.1.6

    Release 5.1.6
    jennantilla authored May 1, 2024
    Copy the full SHA
    67bc03c View commit details

Commits on May 13, 2024

  1. Copy the full SHA
    077ef93 View commit details
  2. Copy the full SHA
    e26c33b View commit details
  3. Fix doc comment format

    brismithers committed May 13, 2024
    Copy the full SHA
    e6e797f View commit details
  4. Copy the full SHA
    9fa959f View commit details
  5. Copy the full SHA
    efcfea7 View commit details
  6. Copy the full SHA
    452f6bd View commit details

Commits on May 14, 2024

  1. Add iOS version checks consistently

    Remove autorelease pool
    brismithers committed May 14, 2024
    Copy the full SHA
    bd03ab7 View commit details

Commits on May 15, 2024

  1. Merge pull request #881 from OneSignal/push-to-start-live-activities

    Push to Start Live Activities
    brismithers authored May 15, 2024
    Copy the full SHA
    74d614b View commit details

Commits on May 16, 2024

  1. release commit 5.2.0

    nan-li committed May 16, 2024
    Copy the full SHA
    acceb97 View commit details
  2. Merge pull request #889 from OneSignal/rel/5.2.0

    Release 5.2.0
    nan-li authored May 16, 2024
    Copy the full SHA
    b9e6c44 View commit details

Commits on Jun 13, 2024

  1. Copy the full SHA
    894e77c View commit details

Commits on Jun 21, 2024

  1. release commit 5.2.1

    jennantilla committed Jun 21, 2024
    Copy the full SHA
    1d3b731 View commit details
  2. Copy the full SHA
    c2176bb View commit details
  3. Merge pull request #906 from OneSignal/rel/5.2.1

    Release 5.2.1
    jennantilla authored Jun 21, 2024
    Copy the full SHA
    dcd8d86 View commit details

Commits on Jun 27, 2024

  1. Copy the full SHA
    1f13b18 View commit details

Commits on Jul 3, 2024

  1. nit: dart linter

    nan-li committed Jul 3, 2024
    Copy the full SHA
    320e5c2 View commit details
  2. release commit 5.2.2

    jennantilla committed Jul 3, 2024
    Copy the full SHA
    9b759b8 View commit details
  3. Merge pull request #901 from zvikarp/main

    chore: add warning for identity verification
    jennantilla authored Jul 3, 2024
    Copy the full SHA
    354cdfa View commit details
  4. Merge pull request #916 from OneSignal/rel/5.2.2

    Release 5.2.2
    jennantilla authored Jul 3, 2024
    Copy the full SHA
    66b669b View commit details

Commits on Aug 9, 2024

  1. Set wrapper sdk type before calling initialize

    * Set the wrapper SDK type first so when initialize is called, the native SDK can check if the SDK is a wrapper type in order to conditionally omit a misleading fatal log
    * See OneSignal/OneSignal-iOS-SDK#1468
    nan-li committed Aug 9, 2024
    Copy the full SHA
    a02fbb0 View commit details

Commits on Aug 15, 2024

  1. Merge pull request #932 from OneSignal/feat/switch_order_to_set_wrapp…

    …er_sdk
    
    Set wrapper sdk type before calling initialize
    nan-li authored Aug 15, 2024
    Copy the full SHA
    29dc397 View commit details
  2. Merge pull request #914 from Sikandar4747/main

    Removed duplicate "longer" MIGRATION_GUIDE.md
    jennantilla authored Aug 15, 2024
    Copy the full SHA
    d0f019a View commit details
  3. release commit

    jennantilla committed Aug 15, 2024
    Copy the full SHA
    f126fc5 View commit details
  4. Merge pull request #933 from OneSignal/rel/5.2.3

    Release 5.2.3
    jennantilla authored Aug 15, 2024
    Copy the full SHA
    3739275 View commit details

Commits on Aug 19, 2024

  1. set compileSdkVersion 34 to fix build errors

    Newer versions of Flutter require newer compileSdkVersion
    jkasten2 committed Aug 19, 2024
    Copy the full SHA
    e3de934 View commit details
  2. Merge pull request #935 from OneSignal/android_compile_version_34

    set compileSdkVersion 34 to fix build errors
    jkasten2 authored Aug 19, 2024
    Copy the full SHA
    7e921f0 View commit details

Commits on Aug 23, 2024

  1. release commit 5.2.4

    nan-li committed Aug 23, 2024
    Copy the full SHA
    2a9e639 View commit details

Commits on Aug 29, 2024

  1. Merge pull request #941 from OneSignal/rel/5.2.4

    Release 5.2.4
    jennantilla authored Aug 29, 2024
    Copy the full SHA
    a9d192c View commit details

Commits on Sep 6, 2024

  1. release commit

    jennantilla committed Sep 6, 2024
    Copy the full SHA
    c364982 View commit details
  2. Merge pull request #948 from OneSignal/rel/5.2.5

    Release 5.2.5
    jennantilla authored Sep 6, 2024
    Copy the full SHA
    92e6094 View commit details

Commits on Oct 2, 2024

  1. release commit

    jennantilla committed Oct 2, 2024
    Copy the full SHA
    8a172fe View commit details

Commits on Oct 3, 2024

  1. Merge pull request #960 from OneSignal/rel/5.2.6

    Release 5.2.6
    jennantilla authored Oct 3, 2024
    Copy the full SHA
    9e7934c View commit details

Commits on Nov 5, 2024

  1. release commit

    jennantilla committed Nov 5, 2024
    Copy the full SHA
    d85855c View commit details
  2. Merge pull request #969 from OneSignal/rel/5.2.7

    Release 5.2.7
    jennantilla authored Nov 5, 2024
    Copy the full SHA
    805b76d View commit details

Commits on Nov 26, 2024

  1. release commit

    jennantilla committed Nov 26, 2024
    Copy the full SHA
    e714f19 View commit details
  2. Merge pull request #976 from OneSignal/rel/5.2.8

    Release 5.2.8
    jennantilla authored Nov 26, 2024
    Copy the full SHA
    2736cc8 View commit details

Commits on Dec 18, 2024

  1. release commit

    jennantilla committed Dec 18, 2024
    Copy the full SHA
    b19d144 View commit details
  2. Merge pull request #982 from OneSignal/rel/5.2.9

    Release 5.2.9
    jennantilla authored Dec 18, 2024
    Copy the full SHA
    a222579 View commit details

Commits on Feb 7, 2025

  1. Switch docs for setShared and isShared

    The descriptions for these two methods appear to have been switched. This change switches them back to how they probably should be.
    JosephCarrington authored Feb 7, 2025
    Copy the full SHA
    e7fb980 View commit details

Commits on Feb 19, 2025

  1. [breaking] remove deprecated v1 embedding references

    * Remove references to the now deprecated v1 Android embedding. `PluginRegistry.Registrar` and `io.flutter.view.FlutterNativeView` classes so that the SDK can be used on newer Flutter versions.
    * Most imports were unused and leftover from when v2 support was added.
    * However, we now need to completely drop v1 support.
    nan-li committed Feb 19, 2025
    Copy the full SHA
    60dcfc4 View commit details
  2. [nit] rename FlutterRegistrarResponder class

    * Now that it is not a Registrar, the name is misleading, rename to `FlutterMessengerResponder`
    nan-li committed Feb 19, 2025
    Copy the full SHA
    b02dc92 View commit details
Showing with 800 additions and 173 deletions.
  1. +2 −3 .github/ISSUE_TEMPLATE/ask-question.yml
  2. +2 −3 .github/ISSUE_TEMPLATE/bug-report.yml
  3. +2 −3 .github/ISSUE_TEMPLATE/general-feedback.yml
  4. +17 −0 .github/workflows/project.yml
  5. +12 −2 MIGRATION_GUIDE.md
  6. +13 −0 README.md
  7. +3 −3 android/build.gradle
  8. +1 −4 ...main/java/com/onesignal/flutter/{FlutterRegistrarResponder.java → FlutterMessengerResponder.java}
  9. +1 −10 android/src/main/java/com/onesignal/flutter/OneSignalDebug.java
  10. +2 −5 android/src/main/java/com/onesignal/flutter/OneSignalInAppMessages.java
  11. +1 −10 android/src/main/java/com/onesignal/flutter/OneSignalLocation.java
  12. +36 −18 android/src/main/java/com/onesignal/flutter/OneSignalNotifications.java
  13. +2 −32 android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java
  14. +1 −11 android/src/main/java/com/onesignal/flutter/OneSignalPushSubscription.java
  15. +0 −4 android/src/main/java/com/onesignal/flutter/OneSignalSerializer.java
  16. +1 −6 android/src/main/java/com/onesignal/flutter/OneSignalSession.java
  17. +1 −6 android/src/main/java/com/onesignal/flutter/OneSignalUser.java
  18. +1 −1 example/android/app/build.gradle
  19. +11 −0 example/ios/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json
  20. +13 −0 example/ios/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
  21. +6 −0 example/ios/ExampleWidget/Assets.xcassets/Contents.json
  22. +11 −0 example/ios/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json
  23. +21 −0 example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json
  24. BIN example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png
  25. +17 −0 example/ios/ExampleWidget/ExampleWidgetBundle.swift
  26. +66 −0 example/ios/ExampleWidget/ExampleWidgetLiveActivity.swift
  27. +11 −0 example/ios/ExampleWidget/Info.plist
  28. +1 −1 example/ios/Flutter/AppFrameworkInfo.plist
  29. +3 −3 example/ios/Flutter/Flutter.podspec
  30. +5 −1 example/ios/Podfile
  31. +25 −20 example/ios/Podfile.lock
  32. +232 −7 example/ios/Runner.xcodeproj/project.pbxproj
  33. +1 −1 example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  34. +6 −4 example/ios/Runner/Info.plist
  35. +87 −1 example/lib/main.dart
  36. +77 −1 ios/Classes/OSFlutterLiveActivities.m
  37. +3 −3 ios/Classes/OneSignalPlugin.m
  38. +2 −2 ios/onesignal_flutter.podspec
  39. +2 −0 lib/onesignal_flutter.dart
  40. +98 −4 lib/src/liveactivities.dart
  41. +3 −3 lib/src/location.dart
  42. +1 −1 pubspec.yaml
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/ask-question.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: 🙋‍♂️ Ask a question
description: Tell us what's on your mind
title: "[question]: "
labels: ["question"]
# assignees:
# - OneSignal/ios-sdk
labels: ["Question"]

body:
- type: markdown
attributes:
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: 🪳 Bug report
description: File a bug report
title: "[Bug]: "
labels: ["bug", "triage"]
# assignees:
# - OneSignal/ios-sdk
labels: ["Bug"]

body:
- type: markdown
attributes:
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/general-feedback.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: 📣 General feedback
description: Tell us what's on your mind
title: "[Feedback]: "
labels: ["triage"]
# assignees:
# - OneSignal/ios-sdk
labels: ["Feedback"]

body:
- type: markdown
attributes:
17 changes: 17 additions & 0 deletions .github/workflows/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Add issues to project

on:
issues:
types:
- opened

jobs:
add-to-project:
runs-on: ubuntu-latest
steps:
- name: Add issue to project
uses: actions/add-to-project@v1.0.2
with:
# SDK Cross-Platform Project
project-url: https://github.com/orgs/OneSignal/projects/10
github-token: ${{ secrets.GH_PROJECTS_TOKEN }}
14 changes: 12 additions & 2 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Flutter v5.0.0 Migration Guide

#### ⚠️ Migration Advisory for current OneSignal customers

Our new [user-centric APIs and v5.x.x SDKs](https://onesignal.com/blog/unify-your-users-across-channels-and-devices/) offer an improved user and data management experience. However, they may not be at 1:1 feature parity with our previous versions yet.

If you are migrating an existing app, we suggest using iOS and Android’s Phased Rollout capabilities to ensure that there are no unexpected issues or edge cases. Here is the documentation for each:

- [iOS Phased Rollout](https://developer.apple.com/help/app-store-connect/update-your-app/release-a-version-update-in-phases/)
- [Google Play Staged Rollouts](https://support.google.com/googleplay/android-developer/answer/6346149?hl=en)

If you run into any challenges or have concerns, please contact our support team at support@onesignal.com

# Intro

@@ -122,7 +132,7 @@ Logging out has the affect of reverting to a device-scoped user, which is the ne

## Subscriptions

In previous versions of the SDK, a “player” could have up to one email address and up to one phone number for SMS. In the user-centered model, a user can own the current device’s **Push Subscription** along with the ability to have **zero or more** email subscriptions and **zero or more** SMS subscriptions. Note: If a new user logs in via the `login` method, the previous user will no longer longer own that push subscription.
In previous versions of the SDK, a “player” could have up to one email address and up to one phone number for SMS. In the user-centered model, a user can own the current device’s **Push Subscription** along with the ability to have **zero or more** email subscriptions and **zero or more** SMS subscriptions. Note: If a new user logs in via the `login` method, the previous user will no longer own that push subscription.

### **Push Subscription**
The current device’s push subscription can be retrieved via:
@@ -442,4 +452,4 @@ The Debug namespace is accessible via `OneSignal.Debug` and provide access to de

# Known issues
- Identity Verification
- We will be introducing JWT in a follow up release
- We will be introducing JWT in a follow up release
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,19 @@

---

#### ⚠️ Migration Advisory for current OneSignal customers

Our new [user-centric APIs and v5.x.x SDKs](https://onesignal.com/blog/unify-your-users-across-channels-and-devices/) offer an improved user and data management experience. However, they may not be at 1:1 feature parity with our previous versions yet.

If you are migrating an existing app, we suggest using iOS and Android’s Phased Rollout capabilities to ensure that there are no unexpected issues or edge cases. Here is the documentation for each:

- [iOS Phased Rollout](https://developer.apple.com/help/app-store-connect/update-your-app/release-a-version-update-in-phases/)
- [Google Play Staged Rollouts](https://support.google.com/googleplay/android-developer/answer/6346149?hl=en)

If you run into any challenges or have concerns, please contact our support team at support@onesignal.com

---

[OneSignal](https://onesignal.com/) is a free email, sms, push notification, and in-app message service for mobile apps. This SDK makes it easy to integrate your Flutter iOS and/or Android apps with OneSignal.

<p align="center"><img src="https://app.onesignal.com/images/android_and_ios_notification_image.gif" width="500" alt="Flutter Notification"></p>
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.onesignal.flutter'
version '5.1.3'
version '5.3.2'

buildscript {
repositories {
@@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 34
// Condition for namespace compatibility in AGP <4.2
if (project.android.hasProperty("namespace")) {
namespace 'com.onesignal.flutter'
@@ -38,5 +38,5 @@ android {
}

dependencies {
implementation 'com.onesignal:OneSignal:5.1.6'
implementation 'com.onesignal:OneSignal:5.1.33'
}
Original file line number Diff line number Diff line change
@@ -4,15 +4,12 @@
import android.os.Handler;
import android.os.Looper;

import com.onesignal.OneSignal;

import java.util.HashMap;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;

abstract class FlutterRegistrarResponder {
abstract class FlutterMessengerResponder {
Context context;
protected MethodChannel channel;
BinaryMessenger messenger;
11 changes: 1 addition & 10 deletions android/src/main/java/com/onesignal/flutter/OneSignalDebug.java
Original file line number Diff line number Diff line change
@@ -3,22 +3,13 @@
import com.onesignal.OneSignal;
import com.onesignal.debug.LogLevel;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class OneSignalDebug extends FlutterRegistrarResponder implements MethodCallHandler {
public class OneSignalDebug extends FlutterMessengerResponder implements MethodCallHandler {

static void registerWith(BinaryMessenger messenger) {
OneSignalDebug controller = new OneSignalDebug();
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@
import com.onesignal.OneSignal;
import com.onesignal.debug.internal.logging.Logging;
import org.json.JSONException;
import org.json.JSONObject;
import com.onesignal.inAppMessages.IInAppMessage;

import com.onesignal.inAppMessages.IInAppMessageClickListener;
import com.onesignal.inAppMessages.IInAppMessageClickEvent;
import com.onesignal.inAppMessages.IInAppMessageClickResult;
import com.onesignal.inAppMessages.IInAppMessageLifecycleListener;
import com.onesignal.inAppMessages.IInAppMessageWillDisplayEvent;
import com.onesignal.inAppMessages.IInAppMessageDidDisplayEvent;
@@ -21,9 +19,8 @@
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class OneSignalInAppMessages extends FlutterRegistrarResponder implements MethodCallHandler,
public class OneSignalInAppMessages extends FlutterMessengerResponder implements MethodCallHandler,
IInAppMessageClickListener, IInAppMessageLifecycleListener{

static void registerWith(BinaryMessenger messenger) {
Original file line number Diff line number Diff line change
@@ -3,22 +3,13 @@
import com.onesignal.OneSignal;
import com.onesignal.Continue;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class OneSignalLocation extends FlutterRegistrarResponder implements MethodCallHandler {
public class OneSignalLocation extends FlutterMessengerResponder implements MethodCallHandler {

static void registerWith(BinaryMessenger messenger) {
OneSignalLocation controller = new OneSignalLocation();
Original file line number Diff line number Diff line change
@@ -1,45 +1,65 @@
package com.onesignal.flutter;

import androidx.annotation.NonNull;

import com.onesignal.debug.internal.logging.Logging;
import com.onesignal.OneSignal;
import com.onesignal.Continue;


import com.onesignal.notifications.INotification;
import com.onesignal.notifications.INotificationClickEvent;
import com.onesignal.notifications.INotificationWillDisplayEvent;
import com.onesignal.notifications.INotificationClickResult;
import com.onesignal.notifications.INotificationReceivedEvent;
import com.onesignal.notifications.INotificationClickListener;
import com.onesignal.notifications.INotificationLifecycleListener;
import com.onesignal.notifications.IPermissionObserver;

import com.onesignal.user.subscriptions.ISubscription;
import com.onesignal.user.subscriptions.IPushSubscription;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlinx.coroutines.Dispatchers;

public class OneSignalNotifications extends FlutterRegistrarResponder implements MethodCallHandler, INotificationClickListener, INotificationLifecycleListener, IPermissionObserver {
public class OneSignalNotifications extends FlutterMessengerResponder implements MethodCallHandler, INotificationClickListener, INotificationLifecycleListener, IPermissionObserver {
private final HashMap<String, INotificationWillDisplayEvent> notificationOnWillDisplayEventCache = new HashMap<>();
private final HashMap<String, INotificationWillDisplayEvent> preventedDefaultCache = new HashMap<>();

/**
* A helper class to encapsulate invoking the suspending function [requestPermission] in Java.
* To support API level < 24, the SDK cannot use the OneSignal-defined [Continue.with] helper method.
*/
private class RequestPermissionContinuation implements Continuation<Boolean> {

private final MethodChannel.Result result;

public RequestPermissionContinuation(MethodChannel.Result result) {
this.result = result;
}

@NonNull
@Override
public CoroutineContext getContext() {
return (CoroutineContext) Dispatchers.getMain();
}

@Override
public void resumeWith(@NonNull Object o) {
if (o instanceof kotlin.Result.Failure) {
Throwable e = ((kotlin.Result.Failure) o).exception;
replyError(result, "OneSignal", "requestPermission failed with error: " + e.getMessage() + "\n" + e.getStackTrace(), null);
}
else {
replySuccess(result, o);
}
}
}

static void registerWith(BinaryMessenger messenger) {
OneSignalNotifications controller = new OneSignalNotifications();
@@ -84,9 +104,7 @@ private void requestPermission(MethodCall call, Result result) {
return;
}

OneSignal.getNotifications().requestPermission(fallback, Continue.with(permissionResult -> {
replySuccess(result, permissionResult.getData());
}));
OneSignal.getNotifications().requestPermission(fallback, new RequestPermissionContinuation(result));
}

private void removeNotification(MethodCall call, Result result) {
34 changes: 2 additions & 32 deletions android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
package com.onesignal.flutter;

import android.annotation.SuppressLint;
import android.content.Context;

import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;

import com.onesignal.OneSignal;
import com.onesignal.Continue;
import com.onesignal.common.OneSignalWrapper;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.view.FlutterNativeView;

/** OnesignalPlugin */
public class OneSignalPlugin extends FlutterRegistrarResponder implements FlutterPlugin, MethodCallHandler, ActivityAware {
public class OneSignalPlugin extends FlutterMessengerResponder implements FlutterPlugin, MethodCallHandler, ActivityAware {

public OneSignalPlugin() {
}
@@ -40,7 +28,7 @@ private void init(Context context, BinaryMessenger messenger)
this.messenger = messenger;
OneSignalWrapper.setSdkType("flutter");
// For 5.0.0, hard code to reflect SDK version
OneSignalWrapper.setSdkVersion("050103");
OneSignalWrapper.setSdkVersion("050302");

channel = new MethodChannel(messenger, "OneSignal");
channel.setMethodCallHandler(this);
@@ -87,24 +75,6 @@ public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBindin
public void onDetachedFromActivityForConfigChanges() {
}

// This static method is only to remain compatible with apps that don’t use the v2 Android embedding.
@Deprecated()
@SuppressLint("Registrar")
public static void registerWith(Registrar registrar) {
final OneSignalPlugin plugin = new OneSignalPlugin();
plugin.init(registrar.activeContext(), registrar.messenger());

// Create a callback for the flutterRegistrar to connect the applications onDestroy
registrar.addViewDestroyListener(new PluginRegistry.ViewDestroyListener() {
@Override
public boolean onViewDestroy(FlutterNativeView flutterNativeView) {
// Remove all handlers so they aren't triggered with wrong context
plugin.onDetachedFromEngine();
return false;
}
});
}

@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.contentEquals("OneSignal#initialize"))
Loading