Upgrading to React Native SDK v2
Version 2 and above of our React Native SDK depends on AndroidX and therefore needs React Native 0.60+
Upgrade your dependency
npm install react-native-wonderpush@2
Android-specific changes
minSdkVersion
changes
minSdkVersion
changesWe 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/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
npm add react-native-wonderpush-fcm
react-native link react-native-wonderpush-fcm
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
.
React Native 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!
Updated about 4 years ago