sona makes possible using getui push in flutter.
Sona
是个推推送SDK在Flutter
上的实现。通过Sona
,可以在Flutter上轻松使用个推推送。
使用Sona
之前,请到个推官网进行应用注册。
鉴于Android
和iOS
的差异化,对应平台设置还需手动设置,具体请参考官网。
在Flutter
中通过Sona
初使化个推推送:
import 'package:sona/sona.dart' as sona;
sona.register(
appID: "your app id",
appKey: "your app key",
appSecret: "app secret"
);
appID
,appKey
,appSecret
目前仅在iOS
上生效,因为在android
上,这些配置是在build.gradle
中完成的,所以使用Sona
之前
一定要在android
工程配置appID
、appKey
以及appSecret
:
defaultConfig {
//some configrations
manifestPlaceholders = [
GETUI_APP_ID : "APP_ID",
GETUI_APP_KEY : "APP_KEY",
GETUI_APP_SECRET : "APP_SECRET"
]
}
通过监听receivedMessageData
可以获取个推推送的透传数据:
sona.receivedMessageData.listen((payload){
//接收到透传
});
其中payload为Map<dynamic,dynamic>
根据平台不台,其包含的key也不同:
- appID:String
- taskID:String
- messageID:String
- offLine:bool
- payload:String or null
- pkgName:String,仅安卓平台