当应用程序是在后台而不是推送通知剂量不工作暂停,当APP是开放的 [英] Push notification dose not work when APP is in background but not suspended and when APP is open

查看:198
本文介绍了当应用程序是在后台而不是推送通知剂量不工作暂停,当APP是开放的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android和iOS推送通知时,在APP收到新推时,应用程序是在前台/打开或不弹出,当它在背景,但不暂停(不是杀死)。

In android and iOS push notification doesn't pop up when a new push is received on the APP when App is in foreground/ Open or when it is in background but not suspended( Not killed).

要接收新推弹出,我需要杀应用程序,然后只有我会接受它。

To receive a new push pop up I need to kill the app then only i would receive it.

我用下面的插件科尔多瓦:
https://github.com/phonegap/phonegap-plugin-push

I'm using the following plug-in for cordova: https://github.com/phonegap/phonegap-plugin-push

科尔多瓦版本:
5.3.1

Cordova version: 5.3.1

我也试图找到一个解决方案,如果有人可以点我在正确的方向那么这将是非常有益的。

I did try to find a solution for this if anyone could point me in right direction then it would be very helpful.

推荐答案

是的,这个插件这种方式工作时,触发onreceived JavaScript事件,但是当应用程序是在前台通知未显示在通知栏。

Yes, this plugin works this way, the onreceived javascript event is triggered, but the notification is not displayed in the notification bar when the app is in foreground.

在Android上,在过去的版本中,你可以改变这种行为,做你的init是这样的:

In android, in the last version, you can change this behaviour, doing your init like this:

that.push = PushNotification.init({ 
                        "android": {
                            "senderID": that.GOOGLE_SENDER_ID,
                            "iconColor": "gray",
                            "icon": "icon_notification",
                            "forceShow": true
                        },
                        "ios": {}, 
                        "windows": {} 
                });

在forceShow,允许该应用显示通知时,应用程序是在前台。

the forceShow, allows the app to show the notification when the app is in foreground.

在IOS是不可能在这个时候,有一个拉要求实现这一目标,对于1.6版本,但我tryied的code和我一直无法使它工作

In IOS is not possible in this moment, there is a pull request to achieve that, for the 1.6 version, but I tryied the code and I have been unable to make it work

在这里你有链接

https://github.com/phonegap/phonegap-plugin-push/拉/ 383

到现在,我在做一个IOS workarround,显示通过JS假的通知,与此库

By the moment, I did a workarround in IOS, showing fake notifications via JS, with this library

http://taitems.github.io/UX-Lab/iOSNotification/ index.html的

另外,我不知道为什么,当应用程序被暂停通知不显示,这发生在Android和iOS设备?

Also, I dont know why the notification doesn't show when the APP is suspended, This happens in both Android and IOS?

在IOS,必须添加推送通知的能力和背景模式 - >背景提取和远程通知。也许这是你的问题。

In IOS, you have to add the capabilities of push notifications, and background modes -> background fetch and remote notifications. Maybe this is your problem.

编程快乐!

这篇关于当应用程序是在后台而不是推送通知剂量不工作暂停,当APP是开放的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆