Upgrading to Flutter SDK v2

Android-specific changes

minSdkVersion changes

We have raised the required minSdkVersion to 21, released in 2014 and covers 95% of Android devices.

Make sure your application uses at least 21 in your android/app/build.gradle, otherwise you'll see the following build error:

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.wonderpush:wonderpush-android-sdk:4.0.1] [...]/.gradle/caches/transforms-2/files-2.1/110f18d74c064672b3bb9b02e46b3f51/jetified-wonderpush-android-sdk-4.0.1/AndroidManifest.xml as the library might be using APIs not available in 16
	Suggestion: use a compatible library with a minSdk of at most 16,
		or increase this project's minSdk version to at least 21,
		or use tools:overrideLibrary="com.wonderpush.sdk" to force usage (may lead to runtime failures)

Add the explicit dependency on our FCM compatibility module

In your pubspec.yaml file, replace this:

dependencies:
  wonderpush_flutter: 1.+

with that:

dependencies:
  wonderpush_flutter: 2.+
  wonderpush_fcm_flutter: 1.+

Then run:

flutter pub get

🚧

Troubleshooting the "no push service available" message

E/WonderPush.Push: Cannot refresh push subscription, no push service available

You need to add the following dependency in your pubspec.yaml:

dependencies:
  wonderpush_fcm_flutter: 1.+

Then run:

flutter pub get

AndroidX

How do I know if my project is using AndroidX?

Our SDK now depends on AndroidX to benefit from more modular dependencies.
If your application does not uses AndroidX yet, follow Flutter's Android Migration guide.
Migrating is as easy as clicking on the Refactor > Migrate to AndroidX menu entry in Android Studio.

If your application does not use AndroidX you will see the following Gradle build errors:

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.collection:collection:1.0.0, androidx.cardview:cardview:1.0.0, androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.core:core:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.constraintlayout:constraintlayout:1.1.3, androidx.constraintlayout:constraintlayout-solver:1.1.3, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.annotation:annotation:1.0.0

iOS-specific changes

Upgrade your Notification Service Extension

Open ios/Podfile and replace:

pod 'WonderPushExtension', '~> 3.0'

with that:

pod 'WonderPushExtension', '~> 4.0'

🚧

Please close Xcode before proceeding

Open a Terminal window in your flutter project directory and type:

cd ios
pod install

Provide your clientId and clientSecret to your Notification Service Extension. Find your ios/WonderPushNotificationServiceExtension/NotificationService.swift file and override the following two methods:

import WonderPushExtension

class NotificationService: WPNotificationServiceExtension {

    override class func clientId() -> String {
        return "YOUR_CLIENT_ID"
    }

    override class func clientSecret() -> String {
        return "YOUR_CLIENT_SECRET"
    }

}
#import "NotificationService.h"

@implementation NotificationService

+ (NSString *)clientId {
    return @"YOUR_CLIENT_ID";

}

+ (NSString *)clientSecret {
    return @"YOUR_CLIENT_SECRET";
}

@end

Make sure to give the same values as in your AppDelegate.

Flutter code changes

Remove calls to deprecated APIs

Remove any calls to WonderPush.isReady().
You do not need to wait to use WonderPush.

👍

You're done!