https://pub.flutter-io.cn/packages/jpush_flutter
JPush's officially supported Flutter plugin (Android & iOS). 極光推送官方支持的 Flutter 插件(Android & iOS)。 http://docs.jiguang.cn
安裝 #
在工程 pubspec.yaml 中加入 dependencies
dependencies: jpush_flutter: 0.0.11
配置 #
Android: #
在 /android/app/build.gradle
中添加下列代碼:
android: {
....
defaultConfig {
applicationId "替換成自己應用 ID"
...
ndk {
//選擇要添加的對應 cpu 類型的 .so 庫。
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a',
}
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "appkey", // NOTE: JPush 上注冊的包名對應的 Appkey.
JPUSH_CHANNEL : "developer-default", //暫時填寫默認值即可.
]
}
}
iOS: #
- 在 xcode8 之后需要點開推送選項: TARGETS -> Capabilities -> Push Notification 設為 on 狀態
使用 #
import 'package:jpush_flutter/jpush_flutter.dart';
APIs #
注意 : 需要先調用 JPush.setup 來初始化插件,才能保證其他功能正常工作。