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 minSdk is 25.

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:

Example project:

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 Notifications in 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 example app is only a verification shell for the plugin package.