jpush / jpush/jpush-phonegap-plugin
iOS 被删后台后不能触发 jpush.backgroundNotification 的监听事件
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 922
- Forks
- 350
- PR merge metrics
- No merged PRs in 30d
Description
WARNING: 如果不按照这个表格,我们将无法帮助你,并将忽略你的问题。
你的运行环境
- 插件版本:
- 平台(Android / iOS): iOS
- Cordova version (
cordova -v): 8.1.2 (cordova-lib@8.1.1) - Cordova platform version (
cordova platform ls): ios 4.5.5 - Ionic Version (if using Ionic): CLI 4.12.0
期望效果
- 手机按home进入后台,可以监听 jpush.backgroundNotification 事件并触发回掉.
- 手机双击home键把app在后台删掉(或iOS为了优化内存自动删掉后台)后,依然可以监听 jpush.backgroundNotification 事件并触发回掉.
实际效果
- 手机按home进入后台后,一段时间内还能监听 jpush.backgroundNotification 事件,但过了一段时间(约15分钟)后,即使app还在后台,已经不能监听 jpush.backgroundNotification 事件了
- 手机双击home键并删除app后台后,jpush.backgroundNotification 立即不能被触发。
重现步骤
- 在 home.ts(主页面)中监听 jpush 事件
import {JPush} from "@jiguang-ionic/jpush";
import {TextToSpeech} from "@ionic-native/text-to-speech";
constructor(
public jpush: JPush,
private tts: TextToSpeech,
) {
document.addEventListener(
"jpush.receiveNotification",
(event: any) => {
this.jpushNotification(event, true)
},
false
);
document.addEventListener(
"jpush.backgroundNotification",
(event: any) => {
this.jpushNotification(event, false)
},
false
);
}
jpushNotification(event, showAlert){
var content;
if (this.device.platform == "Android") {
content = event.alert;
} else {
content = event.aps.alert;
}
if (showAlert) {
alert("Receive notification: " + JSON.stringify(event));
}
this.speak(event.extras.content);
}
speak(content){
this.tts.speak({text:mytext,locale:"zh-HK",rate:1.4})
.then(() => console.log('Success'))
.catch((reason: any) => console.log(reason));
}
- 进入极光开发者后台创建推送,并点选了 content-available 选项
- app 在前台或刚进入后台都能正常触发监听事件并播报声音
- app 进入后台一段时间后,或被删后台,能接收推送但监听事件没被触发
背景
你尝试做过些什么?
Debug logs
包括 Android 或 iOS 的日志:
- iOS: XCode logs
- Android: $ adb logcat / Android Studio logcat
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the listed Cordova, iOS platform, Ionic, and JPush versions using the listener setup in home.ts. Compare foreground, background, and removed-from-background states, and collect the requested Xcode logs. Done means the plugin's behavior for each state is established and the issue is either fixed with a verified callback or clearly documented as an iOS limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100