目前消息推送插件, 在 Flutter 使用中, 仅支持推送至 Android (含各厂商通道) 和 iOS 设备.
集成 消息推送 插件之前,需要先向 Apple 申请 APNs 推送证书,然后上传推送证书到 IM 控制台 。之后按照快速接入步骤接入即可。
操作步骤
步骤1:申请 APNs 证书
开启 App 远程推送
1. 登录 苹果开发者中心 网站,单击 Certificates,Identifiers & Profiles 或者侧栏的 Certificates,IDs & Profiles,进入 Certificates, IDS & Profiles 页面。
![](https://qcloudimg.tencent-cloud.cn/image/document/4208affb6647aa0289b726da5165e1d7.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/4208affb6647aa0289b726da5165e1d7.jpeg)
2. 单击 Identifiers 右侧的 +。
![](https://qcloudimg.tencent-cloud.cn/image/document/8fa7135bfd6647738a8442e0d1a3ecf7.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/8fa7135bfd6647738a8442e0d1a3ecf7.png)
3. 您可以参见如下步骤新建一个 AppID,或者在您原有的 AppID 上增加
Push Notification
的 Service
。说明
您 App 的
Bundle ID
不能使用通配符 *
,否则将无法使用远程推送服务。4. 勾选 App IDs,单击 Continue 进行下一步。
![](https://qcloudimg.tencent-cloud.cn/image/document/4a291d3960164fd751ea3b9d0537bfb3.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/4a291d3960164fd751ea3b9d0537bfb3.png)
5. 选择 App,单击 Continue 进行下一步。
![](https://qcloudimg.tencent-cloud.cn/image/document/0c2806957d513577c6920c5a411365fc.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/0c2806957d513577c6920c5a411365fc.jpeg)
6. 配置
Bundle ID
等其他信息,单击 Continue 进行下一步。![](https://qcloudimg.tencent-cloud.cn/image/document/1c09730bc72a68b48b51ea73ab9a02b2.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1c09730bc72a68b48b51ea73ab9a02b2.png)
7. 勾选 Push Notifications,开启远程推送服务。
![](https://qcloudimg.tencent-cloud.cn/image/document/111eeb9a1d9ee330bcf15d3fc4d6ee2b.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/111eeb9a1d9ee330bcf15d3fc4d6ee2b.png)
生成证书
1. 选中您的 AppID,选择 Configure。
![](https://qcloudimg.tencent-cloud.cn/image/document/20c96e02990481d033e9aec3cc5b7087.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/20c96e02990481d033e9aec3cc5b7087.png)
2. 可以看到在 Apple Push Notification service SSL Certificates 窗口中有两个
SSL Certificate
,分别用于开发环境(Development)和生产环境(Production)的远程推送证书,如下图所示:![](https://qcloudimg.tencent-cloud.cn/image/document/e9bf4351ef3565c845f03afbe5f9906e.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/e9bf4351ef3565c845f03afbe5f9906e.jpeg)
3.
我
们先选择开发环境(Development)的 Create Certificate,系统将提示我们需要一个 Certificate Signing Request(CSR)。![](https://qcloudimg.tencent-cloud.cn/image/document/7b5640312d094144d9947f8a9d1c92e8.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/7b5640312d094144d9947f8a9d1c92e8.png)
4. 在 Mac 上打开钥匙串访问工具(Keychain Access),在菜单中选择钥匙串访问 > 证书助理 > 从证书颁发机构请求证书(
Keychain Access - Certificate Assistant - Request a Certificate From a Certificate Authority
)。![](https://qcloudimg.tencent-cloud.cn/image/document/3d4474ae29281503dbd83286b9c5929d.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/3d4474ae29281503dbd83286b9c5929d.png)
5. 输入用户电子邮件地址(您的邮箱)、常用名称(您的名称或公司名),选择存储到磁盘,单击继续,系统将生成一个
*.certSigningRequest
文件。![](https://qcloudimg.tencent-cloud.cn/image/document/463010057fadec7415894b674783fbef.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/463010057fadec7415894b674783fbef.png)
6. 返回上述 步骤3 中 Apple Developer 网站刚才的页面,单击 Choose File 上传生成的
*.certSigningRequest
文件。![](https://qcloudimg.tencent-cloud.cn/image/document/e2935d9c8b139cd53e0e83282180fbaf.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/e2935d9c8b139cd53e0e83282180fbaf.png)
7. 单击 Continue,即可生成推送证书。
![](https://qcloudimg.tencent-cloud.cn/image/document/5f2e93b4fb33d0b51f6667e71b38f024.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5f2e93b4fb33d0b51f6667e71b38f024.png)
8. 单击 Download 下载开发环境的
Development SSL Certificate
到本地。![](https://qcloudimg.tencent-cloud.cn/image/document/89ce5cd8f54ef8ba4c4a64b667e80fc1.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/89ce5cd8f54ef8ba4c4a64b667e80fc1.jpeg)
9. 再次按照上述步骤1 - 8,将生产环境的
Production SSL Certificate
下载到本地。说明
生产环境的证书实际是开发(Sandbox)+生产(Production)的合并证书,可以同时作为开发环境和生产环境的证书使用。
![](https://qcloudimg.tencent-cloud.cn/image/document/4cf04033f93aadf74ea69bffb0b1d71d.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/4cf04033f93aadf74ea69bffb0b1d71d.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1521c6ad33d4d96331007e84af237ce9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1521c6ad33d4d96331007e84af237ce9.png)
10. 双击打开下载的开发环境和生产环境的
SSL Certificate
,系统会将其导入钥匙串中。11. 打开钥匙串应用,在登录 > 我的证书,右键分别导出刚创建的开发环境(
Apple Development IOS Push Service
)和生产环境(Apple Push Services
)的 P12
文件。![](https://qcloudimg.tencent-cloud.cn/image/document/ef2b2da28e7aff08c92ec432ac3f73b1.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ef2b2da28e7aff08c92ec432ac3f73b1.png)
注意
保存
P12
文件时,请务必要为其设置密码。步骤2:上传证书到控制台
1. 登录 即时通信 IM 控制台。
2. 单击目标应用卡片,进入应用的基础配置页面。
![](https://qcloudimg.tencent-cloud.cn/image/document/ffa52adfed47293ed09bfa77470eaccb.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ffa52adfed47293ed09bfa77470eaccb.png)
3. 单击 iOS 原生离线推送设置右侧的添加证书。
4. 选择证书类型,上传 iOS 证书(p.12),设置证书密码,单击确认。
![](https://qcloudimg.tencent-cloud.cn/image/document/352f6288074e9fc26fb5ccbd86dde936.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/352f6288074e9fc26fb5ccbd86dde936.png)
注意
上传证书名最好使用全英文(尤其不能使用括号等特殊字符)。
上传证书需要设置密码,无密码收不到推送。
发布 App Store 的证书需要设置为生产环境,否则无法收到推送。
上传的 p12 证书必须是自己申请的真实有效的证书。
5. 待推送证书信息生成后,记录证书的 ID。
![](https://qcloudimg.tencent-cloud.cn/image/document/b7520d928534e7391c8481a1c193aa17.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/b7520d928534e7391c8481a1c193aa17.png)
操作步骤
步骤1:注册应用到厂商推送平台
离线推送需要将您自己的应用注册到各个厂商的推送平台,得到 AppID 和 AppKey 等参数,来实现离线推送功能。目前国内支持的手机厂商有:小米、华为、荣耀、OPPO、VIVO、魅族,境外支持 Google FCM。
步骤2:IM 控制台配置
注意:
关于点击后续动作选项, 如需使用本插件提供的点击跳转能力, 请保持默认值不变, 即通常是 `打开应用内指定页面` 并带有默认配置.
如需使用上报统计功能, 也请保持此项默认值不变,
厂商推送平台 | IM 控制台配置 |
![]() | ![]() |
厂商推送平台 | IM 控制台配置 |
![]() | ![]() 说明: Client ID 对应 AppID,Client Secret 对应 AppSecret。 |
厂商推送平台 | IM 控制台配置 |
![]() | ![]() |
厂商推送平台 | IM 控制台配置 |
![]() | ![]() |
厂商推送平台 | IM 控制台配置 |
![]() | ![]() |
厂商推送平台 | IM 控制台配置 |
![]() | ![]() |