flutter_huaji_push
TPNS Flutter plugin.
Version
Current package version: 1.2.2
Compatibility
- Flutter: verified in this repository with a modern Flutter plugin toolchain and updated Android Gradle layout.
- iOS: minimum deployment target is
12.0. - Android: plugin
minSdkis25.
Install
Add the dependency in pubspec.yaml:
dependencies:
flutter_huaji_push: ^1.2.2
Usage
Import the package:
import 'package:flutter_huaji_push/flutter_huaji_push.dart';
API documentation:
- General APIs: documents/APIs.md
- Android vendor channel integration: documents/vendor.md
Example project:
- Flutter example app: example/lib/main.dart
Cluster Domain Configuration
If your TPNS cluster is not Guangzhou, configure the cluster domain before registration.
Cluster domains:
- Shanghai:
tpns.sh.tencent.com - Hong Kong:
tpns.hk.tencent.com - Singapore:
tpns.sgp.tencent.com
iOS:
void configureClusterDomainName(String domainStr);
Call this before startXg.
Android:
Add metadata inside the host app application node:
<application>
<meta-data
android:name="XG_SERVER_SUFFIX"
android:value="your-cluster-domain" />
</application>
iOS Setup
- Enable
Push Notificationsin Xcode capabilities. - Ensure the host app deployment target is at least
12.0.
Android Setup
Configure your host app manifest placeholders:
android {
defaultConfig {
applicationId "your.application.id"
manifestPlaceholders = [
XG_ACCESS_ID: "your-access-id",
XG_ACCESS_KEY: "your-access-key",
]
}
}
If you use TPNS vendor channels, also follow documents/vendor.md.
ProGuard / R8 rules:
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep class com.tencent.android.tpush.** {*;}
-keep class com.tencent.tpns.baseapi.** {*;}
-keep class com.tencent.tpns.mqttchannel.** {*;}
-keep class com.tencent.tpns.dataacquisition.** {*;}
-keep class com.tencent.bigdata.baseapi.** {*;}
-keep class com.tencent.bigdata.mqttchannel.** {*;}
Notes
- The plugin iOS entry class is Objective-C
FlutterHuajiPushPlugin. - The
exampleapp is only a verification shell for the plugin package.