差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
im:ios:apns:content [2019/04/17 11:30] jk [APNs推送国际化配置] |
im:ios:apns:content [2022/11/09 07:39] (当前版本) victorli [REST 发送] |
||
---|---|---|---|
行 66: | 行 66: | ||
{ | { | ||
"aps":{ | "aps":{ | ||
- | "alert":"您有一条新消息", | + | "alert":{ |
+ | "body":"您有一条新消息" | ||
+ | }, | ||
"badge":1, | "badge":1, | ||
"sound":"default" | "sound":"default" | ||
行 92: | 行 94: | ||
{ | { | ||
"aps":{ | "aps":{ | ||
- | "alert":"ApnsName:xxxx", | + | "alert":{ |
+ | "body":"ApnsName:xxxx" | ||
+ | }, | ||
"badge":1, | "badge":1, | ||
"sound":"default" | "sound":"default" | ||
行 115: | 行 119: | ||
---- | ---- | ||
- | ===== 向APNs中添加扩展字段 ===== | + | ===== 向 APNs 中添加扩展字段 ===== |
- | APNs扩展(em_apns_ext):添加后,您收到的 APNs 中将带有您填写的字段,可以帮助您区分 APNs。 | + | APNs 扩展(em_apns_ext):添加后,您收到的 APNs 中将带有您填写的字段,可以帮助您区分 APNs。 |
环信提供以下几种扩展字段: | 环信提供以下几种扩展字段: | ||
+ | |||
^扩展字段^描述^ | ^扩展字段^描述^ | ||
|em_push_content|自定义推送显示| | |em_push_content|自定义推送显示| | ||
行 148: | 行 153: | ||
=== REST 发送 === | === REST 发送 === | ||
- | ([[im:server:basics:messages#发送扩展消息|REST 发消息]]) | + | ([[https://docs-im.easemob.com/ccim/rest/message#发送消息|REST 发消息]]) |
<code> | <code> | ||
行 225: | 行 230: | ||
} | } | ||
} | } | ||
+ | </code> | ||
+ | |||
+ | 如果要兼容Android端,需要在消息的扩展中增加以下字段 | ||
+ | <code> | ||
+ | "ext":{ | ||
+ | ... | ||
+ | "em_android_push_ext":{ | ||
+ | //指定自定义渠道 | ||
+ | "em_push_channel_id":"Channel id", | ||
+ | "em_push_sound":"/raw/appsound" | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
行 340: | 行 357: | ||
| | ||
* 集成方式:将自定义提示音的caf格式音频文件导入iOS工程,发送消息按以下示例增加消息扩展,当接收方离线收到APNs离线推送时,即可播放自定义的提示音。 | * 集成方式:将自定义提示音的caf格式音频文件导入iOS工程,发送消息按以下示例增加消息扩展,当接收方离线收到APNs离线推送时,即可播放自定义的提示音。 | ||
+ | |||
+ | 支持格式 Linear PCM | ||
+ | MA4 (IMA/ADPCM) | ||
+ | µLaw | ||
+ | aLaw | ||
+ | |||
+ | 存放路径 | ||
+ | AppData/Library/Sounds,时长不得超过30秒。 | ||
+ | 具体信息,可以参考苹果官方文档[[https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification?language=objc|Generating a Remote Notification]] | ||
+ | |||
=== 解析 === | === 解析 === | ||
行 579: | 行 606: | ||
<code> | <code> | ||
- | EMChatText *txt = [[EMChatText alloc] initWithText:@"test"]; | + | EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:@"test"]; |
- | EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithChatObject:txt]; | + | EMMessage *message = [[EMMessage alloc] initWithConversationID:@"6006" from:@"6001" to:@"6006" body:body ext:nil]; |
- | EMMessage *msg = [[EMMessage alloc] initWithReceiver:@"6001" bodies:@[body]]; | + | message.ext = @{@"em_ignore_notification":@YES}; |
- | // 设置自定义扩展字段 | + | message.chatType = EMChatTypeChat; // 设置消息类型 |
- | msg.ext = @{@"em_ignore_notification":@YES}; | + | // 发送消息示例 |
- | // 发送消息 | + | [EMClient.sharedClient.chatManager sendMessage:message progress:nil completion:nil]; |
- | [[EaseMob sharedInstance].chatManager asyncSendMessage:msg progress:nil]; | + | |
</code> | </code> | ||
行 625: | 行 651: | ||
<code> | <code> | ||
- | EMChatText *txt = [[EMChatText alloc] initWithText:@"test"]; | + | EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:@"test"]; |
- | EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithChatObject:txt]; | + | EMMessage *message = [[EMMessage alloc] initWithConversationID:@"6006" from:@"6001" to:@"6006" body:body ext:nil]; |
- | EMMessage *msg = [[EMMessage alloc] initWithReceiver:@"6001" bodies:@[body]]; | + | message.ext = @{@"em_force_notification":@YES}; |
- | // 设置自定义扩展字段 | + | message.chatType = EMChatTypeChat; // 设置消息类型 |
- | msg.ext = @{@"em_force_notification":@YES}; | + | // 发送消息示例 |
- | // 发送消息 | + | [EMClient.sharedClient.chatManager sendMessage:message progress:nil completion:nil]; |
- | [[EaseMob sharedInstance].chatManager asyncSendMessage:msg progress:nil]; | + | |
</code> | </code> | ||
行 644: | 行 669: | ||
<WRAP half column> | <WRAP half column> | ||
- | 下一页:[[im:ios:other:easeui|EaseUI 使用指南]] | + | 下一页:[[im:ios:other:easeimapp|EaseIM 介绍]] |
</WRAP> | </WRAP> | ||
</WRAP> | </WRAP> | ||