如何在 Android 上即使禁用 Play 服务也能接收推送通知

huangapple go评论68阅读模式
英文:

how to receive push notifications even when the play services are disabled on android

问题

Firebase使用Play服务推送通知,但我正在开发一个Android应用程序,要求在Play服务被禁用且手机处于省电模式时仍能接收推送通知。

我尝试过使用Pushy,但在省电模式下应用程序无法接收通知,我还尝试过使用前台服务,但效果不佳。

英文:

As you know firebase uses play services to push notifications but I am working on an android app that requires to receive push notifications even when the play services are disabled and the phone is on power saving.

I have tried using pushy but the app do not receive notifications in power saving mode, I have also tried using a foreground service but it is of no good.

答案1

得分: 2

这是不可能的,除非修改设备。单个应用程序无法在设备尝试节电时控制设备。否则,每个应用程序都会这样做,设备的电池寿命会受到影响。您必须依赖Play服务来管理通知,或者接受在节电模式下无法执行任何操作。

英文:

It's not possible without modifying the device. Individual apps do not have the ability to control the device when it's trying to save power. Otherwise, every app would do this, and the device's battery life would suffer as a result. You have to either depend on Play services to manage the notification, or accept that you can't do anything at all while power saving.

答案2

得分: -2

很抱歉,Android 设备上没有安装 Google Play 服务的情况下是无法接收 Firebase Cloud Messaging (FCM) 通知的。FCM 依赖于 Google Play 服务基础设施来向设备传递通知。

同样地,Android 设备上的省电模式会限制后台活动,这可能会阻止应用程序接收通知。

一种可能的解决方法是使用不依赖于 Google Play 服务并支持省电模式的第三方推送通知服务。一些此类服务的示例包括 OneSignal、Pusher 和 Amazon SNS。

英文:

Alright.
Unfortunately, it is not possible to receive Firebase Cloud Messaging (FCM) notifications without Google Play Services on Android devices. FCM relies on the Google Play Services infrastructure to deliver notifications to devices.

Similarly, power saving mode on Android devices restricts background activity, which can prevent apps from receiving notifications.

One possible workaround is to use a third-party push notification service that does not rely on Google Play Services and provides support for power saving mode. Some examples of such services include OneSignal, Pusher, and Amazon SNS.

huangapple
  • 本文由 发表于 2023年6月19日 21:17:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76507026.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定