Last updated:
0 purchases
jpush flutter plugin
jpush_flutter_plugin #
Requirement #
Android
iOS
Support
SDK 21+
12.0+
Usage #
dart #
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await setDebugMode(debugMode: true);
await setAuth(auth: true);
await init('your appkey', 'tour channel', (call) {
print('[method]: ${call.method}');
});
/// ...
runApp(const MyApp());
}
copied to clipboard
Android #
dependencies:
flutter:
sdk: flutter
jpush_flutter_plugin: latest
copied to clipboard
android/app/src/main/AndroidManifest.xml
<manifest
xmlns:tools="http://schemas.android.com/tools"
>
<permission
android:name="yourpackage.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="yourpackage.permission.JPUSH_MESSAGE" />
<!-- 网络权限 (必选)-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 查看网络状态,sdk重连机制等需要使用-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 适配Android 13,应用弹出通知必须权限-->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
tools:replace="android:label"
>
<activity>
<!-- ... -->
</activity>
<!-- Required. For publish channel feature -->
<!-- JPUSH_CHANNEL 是为了方便开发者统计 APK 分发渠道。-->
<!-- 例如: -->
<!-- 发到 Google Play 的 APK 可以设置为 google-play; -->
<!-- 发到其他市场的 APK 可以设置为 xxx-market。 -->
<meta-data
android:name="JPUSH_CHANNEL"
android:value="developer-default" />
<!-- Required. AppKey copied from Portal -->
<meta-data
android:name="JPUSH_APPKEY"
android:value="your appkey" />
</application>
</manifest>
copied to clipboard
android/app/build.gradle
android {
// ...
defaultConfig {
// ...
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
// 还可以添加 'mips', 'mips64'
}
}
// ...
packagingOptions {
pickFirst 'lib/x86/libjcore336.so'
pickFirst 'lib/x86_64/libjcore336.so'
pickFirst 'lib/arm64-v8a/libjcore336.so'
pickFirst 'lib/armeabi/libjcore336.so'
pickFirst 'lib/armeabi-v7a/libjcore336.so'
}
}
copied to clipboard
iOS #
ios/Runner/Info.plist
<dict>
<key>NSUserTrackingUsageDescription</key>
<string>申请访问Tracking权限</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
copied to clipboard
Add Capability
Access WiFi Information
Push Notification
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.