Skip to content

JiangJuHong/FlutterXiaoMiPushPlugin

Repository files navigation

[中文文档] [English Docs]

xiao_mi_push_plugin

pub package

Xiaomi Push SDK Flutter plugin Xiaomi Push version: v3.7.6 During testing, please use a real device as an emulator may trigger an exception with the message "code = 10017, msg= Illegal parameter value".

Discussion Group


Click to join the group chat

Requirements

Flutter Version >= 1.12

If you encounter an error with code 22022, please make sure that push services are enabled. For instructions on how to enable push services, please refer to: https://support.rongcloud.cn/ks/NzE5

Configuration

Obfuscation

No additional configuration is required as obfuscation is already built in.

Permissions

Modify the AndroidManifest.xml file and add the following:

<permission android:name="your.package.name.permission.MIPUSH_RECEIVE"
            android:protectionLevel="signature"/>
<uses-permission android:name="your.package.name.permission.MIPUSH_RECEIVE"/>

Usage

API

API Description Parameters
init Initialize { appId: APP_ID , appKey: APP_KEY }
setAlias Set alias { alias: alias, category: category }
unsetAlias Cancel alias { alias: alias, category: category }
getAllAlias Get all aliases -
setUserAccount Set user account { userAccount: account, category: category }
unsetUserAccount Cancel user account { userAccount: account, category: category }
getAllUserAccount Get all user accounts -
subscribe Set tag { topic: topic, category: category }
unsubscribe Cancel tag { topic: topic, category: category }
getAllTopic Get all tags -
getRegId Get client RegId -

Listeners

Add listener: XiaoMiPushPlugin.addListener, remove listener: XiaoMiPushPlugin.removeListener
Listener method prototype: typedef ListenerValue<P> = void Function(XiaoMiPushListenerTypeEnum type, P params);

Type Description Format
NotificationMessageClicked Receive notification messages pushed by the server and trigger when the user clicks MiPushMessageEntity
RequirePermissions Callback when the required permissions are not obtained List
ReceivePassThroughMessage Receive pass-through messages pushed by the server MiPushMessageEntity
CommandResult Get the result of the command sent to the server MiPushCommandMessageEntity
ReceiveRegisterResult Get the result of the registration command sent to the server MiPushCommandMessageEntity
NotificationMessageArrived Receive notification messages pushed by the server, trigger when the message arrives at the client, and also receive notification messages that do not pop up when the application is in the foreground (on MIUI, only when the application is in a running state or on the self-starting whitelist can this method be used to receive such messages). | MiPushMessageEntity |

Other Plugins

I also maintain the following plugins. If you are interested in maintaining them with me, please contact me through Github. Issues and PRs are welcome.

Platform Plugin Description Version
Flutter FlutterVideoPlayerLibrary-Desc The best player (UI library) for Flutter -
Flutter FlutterPerfectVolumeControl Flutter's perfect volume controller plugin pub package
Flutter FlutterTencentImPlugin Tencent Cloud IM plugin pub package
Flutter FlutterTencentRtcPlugin Tencent Cloud Rtc plugin pub package
Flutter FlutterXiaoMiPushPlugin Xiaomi Push SDK plugin pub package
Flutter FlutterHuaWeiPushPlugin Huawei Push (HMS Push) plugin pub package
Flutter FlutterTextSpanField Custom text style input box pub package
Flutter FlutterClipboardListener Clipboard listener pub package
Flutter FlutterQiniucloudLivePlugin Flutter Qiniu Cloud Live plugin Not