简介
本文档提供移动推送 iOS 应用快速接入指引。使用本地工具无代码集成,一键为您的 iOS 应用配置推送功能。
注意
接入前准备
创建 iOS 平台应用
2. 在配置管理页面上传推送证书,您可以参见 证书获取指引 操作获取推送证书。
![](https://qcloudimg.tencent-cloud.cn/image/document/4e46a7f42495431e61afc0d352c431fe.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/4e46a7f42495431e61afc0d352c431fe.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a0a92581201a7e291fc3a0e2e9670a4a.png)
3. 完成以上步骤后,单击快速接入,下载快速集成工具。
![](https://qcloudimg.tencent-cloud.cn/image/document/bf60acb63f322f9c81095140d0bbc4e1.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/bf60acb63f322f9c81095140d0bbc4e1.png)
4. 解压缩文件包,双击TPNS Smart Tool。
![](https://qcloudimg.tencent-cloud.cn/image/document/9fdbd70874b5a6e84b37b99ff809b26e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/9fdbd70874b5a6e84b37b99ff809b26e.png)
5. 此时会提示“无法打开 TPNS Smart Tool”。
![](https://qcloudimg.tencent-cloud.cn/image/document/24788301a27717c2b20ea7259724350e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/24788301a27717c2b20ea7259724350e.png)
6. 前往系统偏好设置>安全性与隐私> 通用中单击仍要打开。
![](https://qcloudimg.tencent-cloud.cn/image/document/7c652689f5a7e34d9b543670893dc417.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/7c652689f5a7e34d9b543670893dc417.jpeg)
7. 按照系统提示输入本机密码确认操作,正确无误后再次单击仍要打开,此时会出现打开,单击打开。
![](https://qcloudimg.tencent-cloud.cn/image/document/5314852f77f9a420f881d520629bb61f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5314852f77f9a420f881d520629bb61f.png)
开始接入
1. 启动一键集成工具之后,进入首页,单击开始集成。
![](https://qcloudimg.tencent-cloud.cn/image/document/a53eebd0dccb90cca6a41e2949e43507.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/a53eebd0dccb90cca6a41e2949e43507.jpeg)
2. 进入配置页面,下面我们逐一对6个配置项进行说明
![](https://qcloudimg.tencent-cloud.cn/image/document/0710221660c500532f29bd4b36c56057.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/0710221660c500532f29bd4b36c56057.jpeg)
配置项1、2 - AccessID、AccessKey
1. 产品管理 - 要配置推送能力的产品,选择 iOS 或者 macOS 平台的配置管理。
![](https://qcloudimg.tencent-cloud.cn/image/document/af004ddaad1824a21f03009631e6ec9b.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/af004ddaad1824a21f03009631e6ec9b.png)
2. 进入基础配置详情页,分别复制 AccessID 和 AccessKey,粘贴到一键集成工具对应的输入框内。
![](https://qcloudimg.tencent-cloud.cn/image/document/9f8e96dcd0def70ed55b5ad8e2cfbb3e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/9f8e96dcd0def70ed55b5ad8e2cfbb3e.png)
配置项3 - 选择工程语言
请根据
AppDelegate
文件所使用的语言选择:AppDelegate.m
- 请选择 Objective-C
AppDelegate.swift
- 请选择 Swift
配置项4 - 选择工程文件
请选择 ![](https://qcloudimg.tencent-cloud.cn/image/document/8a762f752d00f717b549009a12c29c31.jpeg)
.xcodeproj
后缀的工程文件:
![](https://qcloudimg.tencent-cloud.cn/image/document/8a762f752d00f717b549009a12c29c31.jpeg)
配置项5 - 基础推送能力
基础推送能力:正常的推送通知能力,不包含推送数据触达率统计、富媒体推送等功能。
配置项6 - 通知服务扩展插件
通知服务扩展插件:主要用于统计推送数据的触达率以及实现富媒体推送等功能。
若您的
Xcode
选择是自动签名,则 Xcode
会在苹果开发者平台为您的通知扩展插件生成描述文件(Provisioning File)。若您的
Xcode
选择是手动签名,则需要到苹果开发者平台手动生成描述文件(Provisioning File),否则将导致应用程序无法安装到真机调试,操作步骤如下:1. 前往 苹果开发者平台 为通知服务扩展插件申请
Bundle Identifier
。说明
Bundle Identifier
命名规则 (主target Bundle Identifier).TPNSService。2. 申请包含 ![](https://qcloudimg.tencent-cloud.cn/image/document/3c89128b464b6b2f50b620a71318db06.png)
Bundle Identifier
的描述文件。
![](https://qcloudimg.tencent-cloud.cn/image/document/3c89128b464b6b2f50b620a71318db06.png)
3. 将扩展插件的 ![](https://qcloudimg.tencent-cloud.cn/image/document/df91abb8aeae0c41e117b5e57e6e3119.png)
Bundle Identifier
指定为上述申请的 Bundle Identifier
并将 Provisioning Profile
指定为上述申请的描述文件。
![](https://qcloudimg.tencent-cloud.cn/image/document/df91abb8aeae0c41e117b5e57e6e3119.png)
说明
若您是初次集成 移动推送,建议同时勾选5和6,否则无法获取推送抵达数据且无法下发富媒体推送。
您可以单独集成配置项5或者6,也可以同时集成5和6,请根据您的项目情况自行选择。
进行移动推送 SDK 集成
1. 完成上述6项配置之后,一键集成将变成蓝色可单击状态,单击一键集成。
![](https://qcloudimg.tencent-cloud.cn/image/document/4c592fc09c2f93885f3d45b848451743.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/4c592fc09c2f93885f3d45b848451743.jpeg)
2. 集成成功之后,将展示如下弹框。
![](https://qcloudimg.tencent-cloud.cn/image/document/fb2030938a852fe8296fa6423f25b31d.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/fb2030938a852fe8296fa6423f25b31d.jpeg)
集成成功后的项目结构及工程配置
如果集成成功,项目结构和工程配置应该如下图所示:
![](https://qcloudimg.tencent-cloud.cn/image/document/ed5af9720be524cb7972c98b1f3cbcba.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/f2c24970d7acb37cba9fb97ddb09aeeb.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/ed5af9720be524cb7972c98b1f3cbcba.jpeg)
![](https://qcloudimg.tencent-cloud.cn/image/document/f2c24970d7acb37cba9fb97ddb09aeeb.jpeg)
如果出现编译失败、收不到推送、没有触达率统计数据等情况,请先将您项目的配置与上图进行对比,找出集成错误的地方,并联系 在线客服。
接入结果验证
将 iPhone 设备连接 Xcode,安装 App 并观察控制台日志,若显示如下相似日志,表明客户端已经正确集成 SDK:
[TPNS] Current device token is 9298da5605c3b242261b57****376e409f826c2caf87aa0e6112f944[TPNS] Current TPNS token is 00c30e0aeddff1270d8****dc594606dc184