应用关闭时未收到Android推送通知 [英] Android push notifications not being received when app closed

查看:404
本文介绍了应用关闭时未收到Android推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了PushSharp存储库中的示例: PushSharp Android客户端示例

I followed the example in the PushSharp repository at: PushSharp Android Client Sample

如果应用处于打开状态或在后台(通过单击主屏幕或后退按钮),则一切工作都很好.但是,如果我通过在应用程序管理器中将其滑开来关闭该应用程序,则不会再收到通知.

Everything is working great if the app is open or in the background (by hitting home or back button). If I close the app by swiping it away in the application manager I no longer receive notifications, though.

我的假设是,由于PushHandlerService被标记为[Service],因此即使应用程序关闭,它也将保持打开状态并继续侦听通知.有没有办法在应用关闭的状态下继续接收通知,还是我做错了?

My assumption was that since the PushHandlerService is marked as a [Service] that it would remain open even when the app is closed and continue to listen for notifications. Is there a way to continue to receive notifications with the app closed, or am I just doing it wrong?

我将包含代码,但是我所获得的东西完全来自上面链接中的示例.

I would include code but what I've got is taken pretty much exactly from the example at the above link.

我尝试在应用启动时触发PushClient.Register,即使设备已经注册,也希望它能够启动PushHandlerService(如果未启动).即使在每次启动该应用程序时都进行了重新注册,当该应用程序关闭时,我仍然不会收到通知.

I tried firing PushClient.Register on app start even through the device is already registered in hopes that this would start the PushHandlerService if it wasn't started. Even with re-registering on each launch of the app I still don't receive notification when the app is closed.

推荐答案

您是否尝试过使用调试或发布模式?在调试模式下启动应用程序时,我也遇到了同样的情况.

Did you tried it with debug, or release mode? I experienced the same when I started my app in Debug mode.

这篇关于应用关闭时未收到Android推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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