|
极光推送ios应用在后台时收不到推送的消息或者通知。
[复制链接]
本帖最后由 TerryQi 于 2019-11-28 14:57 编辑
极光推送ios应用在后台时收不到推送的消息或者通知。有没有大佬能帮忙解决一下的。代码在下方写的跟乱担待一下。 现在的问题是ios应用在前台的时候可以下收到但是只是提示无法长存
ajpush.init(function (ret) { //初始化极光推送
// 设置推送监听,有回调,
ajpush.setListener(function (ret) { //将收到的系统推送 写到手机push栏中
consoledebug.log('setListener : ' + JSON.stringify(ret))
ret.content = ret.content.replace(/<[^>]+>/g, "")
var extra = {
id: ret.id,
notification_id: ret.extra.jump_module_id,
notification_type: ret.extra.jump_module,
}
notificationSystem(ret.extra.title, ret.content, extra, function (ret, err) {
if (ret) {
//alert(JSON.stringify(ret));
} else {
//alert(JSON.stringify(err));
}
})
});
});
api.addEventListener({ //监听用户点击通知
name: 'noticeclicked'
}, function (ret, err) {
if (ret && ret.value) {
var msgObj = JSON.parse(ret.value)
if (msgObj.notification_type == 'system_message') { //监听 系统消息/聊天消息
// alert(JSON.stringify(msgObj))
openWin('news_details_page_win', './html/news_details_page/', {message_id: msgObj.notification_id}, 2)
} else if (msgObj.notification_type == 'notification_chat') {
// var extra = {notification_type:'notification_chat' , conversationId:msgObj.conversationId , friends_name: msgObj.ext.nick_name , friends_avatar:msgObj.ext.avatar}
setStorage('conversation_id', msgObj.conversationId)
$('#' + msgObj.conversationId).addClass('aui-hide')
openWinNotSlidBack('chat_screen_win', './html/index/', {
friends_id: msgObj.conversationId,
friends_avatar: msgObj.friends_avatar,
friends_name: msgObj.friends_name,
type: '',
}, 1)
}
}
})
<preference name="backgroundMode" value="audio|remote-notification"/> 配置文件
|
|