tencent cloud

移动推送

产品动态
公告
产品功能动态
Android SDK 发布动态
iOS SDK 发布动态
macOS SDK 发布动态
产品简介
产品概述
产品优势
应用场景
全球化部署
购买指南
价格总览
购买指引
计费模式
免费试用
欠费说明
快速入门
创建产品和应用
Android 快速接入
iOS 快速接入
创建推送任务
查询推送记录
推送测试方法指引
产品限制说明
操作指南
推送管理
推送高级功能
实践教程
iOS 平台角标功能实践
API 文档
简介
API 概览
调用方式
推送相关接口
标签相关接口
账号相关接口
统计相关接口
用户属性相关接口
服务端错误码
服务端 SDK
API(Java)
SDK 文档
Android 接入指南
iOS 接入指南
客户端集成插件
macOS接入指南
用户及权限
快速入门配置
进阶自定义配置
资源标签
服务协议
服务等级协议
开发者协议
常见问题
iOS 常见问题
Android 常见问题
Flutter 常见问题
其他问题
移动推送政策
移动推送隐私协议
TPNS 数据处理和安全协议
Developer Agreement
联系我们
词汇表
文档移动推送

iOS SDK FAQs

聚焦模式
字号
最后更新时间: 2024-12-19 17:03:10

Push messages cannot be received

Message push involves various associated modules, and exception in any steps can leads to message delivery failure. Below are the most common issues.

Client troubleshooting

Check device notification settings
Please go to Notifications > App name and check whether your app has the permission to push messages.
Check device network settings
Device network problems may lead to client's failure to obtain message-receiving token when registering APNs, which can prevent TPNS from pushing message to specified devices.
Even if a client correctly obtained token and registered it with TPNS backend, the client will not receive the message after a message is successfully delivered by the TPNS server if the device is not connected to the internet. Device may receive a message if the device connects to the Internet in a short time. APNs will retain the message for a while and deliver it again.
SDK access problem. After the SDK is accessed, please make sure that it can get the device token used to receive messages. For more information, see iOS SDK Integration Guide.

Server troubleshooting

APNs server problem
As a message sent to an iOS device by the TPNS service is delivered via the APNs service, if APNs fails, the request to APNs by the TPNS server to deliver the message to the device will fail.
TPNS server problem
The TPNS server achieves message delivery through the collaboration of multiple feature modules. If any of the modules has a problem, message push will fail.

Push certificate troubleshooting

When the TPNS server requests the APNs to deliver the message, it needs to use two required parameters: the message push certificate and the device token. When pushing the message, please make sure that the message push certificate is valid. For more information about the message push certificate settings, see Notes on iOS Push Certificate.
In order to troubleshoot server problems, you can use the TPNS testing tool, which not only helps verify the conditions of TPNS and APNs servers, but also verifies the validity of the message push certificate and automatically generates the format of the TPNS-specific certificate.
After the certificate is uploaded to the TPNS console, it usually takes about 5 minutes for it to take effect.

Why does account/tag binding or unbinding not work?

When the SDK APIs are used to bind or unbind account or tag, the TPNS server needs about 10 seconds for data synchronization.

Why is the API for registering token missing in the new version?

In iOS SDK v1.0+, the registration of the device token is automated and handled internally by the SDK, eliminating the need for you to manually call the API.

The device prompts for error "No valid 'aps-environment' entitlement string found" .

Please check whether the bundle id configured in the Xcode project matches the configured Provision Profile file, and whether the Provision Profile file corresponding to the app has been configured with the message push capability.

How does the client redirect or respond based on the message content?

When the iOS device receives a push message and the user taps the message to open the app, the app will respond differently according to the status:
This function will be called if the app status is "not running".
If launchOptions contains UIApplicationLaunchOptionsRemoteNotificationKey , it means that the user's tap on the push message causes the app to launch.
If the corresponding key value is not included, it means that the app launch is not because of the tap on the message but probably because of the tap on the icon or other actions.
Sample code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Get the message content
NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
// Then logically handle based on the message content
}

If the app status is "in the foreground" or "in the background but still active":
In iOS 7.0+, if the Remote Notification feature is used, the following handler needs to be used:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
In iOS 10.0+, if the Remote Notification feature is used, it is recommended to add a ``UserNotifications Framework`` handler and use it. In iOS TPNS SDK v1.0+, the TPNS SDK has encapsulated the new framework. Please use the following two methods in the ``XGPushDelegate`` protocol:
Sample code
- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
NSLog(@"[XGDemo] click notification");
completionHandler();
}

// This API needs to be called when the app pops up the push message in the foreground
- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
}

How does the client play custom push message audio?

First, on the device development side, place the audio file in the bundle directory; If you use the TPNS console to create a push, enter the audio file name in Advanced settings (the full path of the audio file is not required). If you use REST API call, set the ``sound`` parameter to the audio file name (the full path of the audio file is not required).

Does iOS support offline retention of push message?

No. When TPSN server sends a message to APNs, if APNs finds that the device is not online, it will retain the message for a while; however, Apple did not disclose the specific retention duration.

Why is arrival data unavailable for iOS?

In versions below iOS 9.x, the operating system does not provide an API to listen to message arrivals at the devices, so the arrival data cannot be collected.In iOS 10.0+, the operating system provides a ``Service Extension`` API, which can be called by the client to listen to message arrivals; however, the current iOS message statistics in TPNS does not include this part of data. Please stay tuned.

How to create silent push using the TPNS server SDK?

Assign a value of 1 to ``content-available `` and do not use alert, badge, or sound.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈