当应用程序未运行 (iphone/android) 时,在远程触发器上创建一个(重复的高音)警报,就像“查找我的 iPhone"一样 [英] Create an (repetitive high pitch) Alarm on a remote trigger when App is not running (iphone/android) just like Find My iPhone

查看:12
本文介绍了当应用程序未运行 (iphone/android) 时,在远程触发器上创建一个(重复的高音)警报,就像“查找我的 iPhone"一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用运行或未运行时在远程 iphone/android 设备上引起警报.

I would like to cause an alarm on a remote iphone/android device when the app is running or not running.

我如何实现它?

当有来电时,我只能想到 Whatsapp/Skype,它正在响铃.或者有没有可能让手机在推送通知上播放循环的闹钟声音.

I can only think of Whatsapp/Skype when there is incoming call, its ringing. Or would it be possible to cause the phone to play a looping alarm sound on Push Notification.

另一个非常明显的例子是查找我的 iPhone"应用,它可以向 iPhone 发出响亮的警报.

Another very clear example is "Find My iPhone" app which can trigger a loud alarm to an iPhone.

如何在 ios 和 android 上以编程方式实现这一点?

How can I achieve this programmatically on ios and android ?

推荐答案

它可以将 FireBase Notification Services 与 JobService & 一起使用FirebaseMessagingService.

  • 从这里下载 FireBase 示例.运行模块messaging".我测试它,我能够收到通知,即使在应用程序终止状态.

  • Download the FireBase samples from here .Run module "messaging".I tested it and I was able to receive the notification , even in the Application killed state.

要定期/安排管理事件,您必须实施 &在某处部署您的服务器.您还可以查看 FireBase 函数(测试版) 以轻松实施服务器.

To manage events periodically/scheduled you must implement & deploy your Server somewhere.You can also check FireBase Functions (Beta) to easily implement Server.

在接收 FireBase 通知的同时向用户显示一些东西(警报/UI 之类的调用屏幕)来启动您的自定义活动.覆盖 FirebaseMessagingService 中的 handleIntent.这样你可以从您的终止/空闲应用程序接收数据.

To show something (Alaram/UI like calling screen) to user start your custom Activity while receiving FireBase notification.Override handleIntent from FirebaseMessagingService.So that you can receive data from your killed/idle Application.

FireBase 服务是系统服务 &它将始终运行.请阅读.

FireBase Service is System Service & it will be always running.Please have a read.

代码片段

@Override
public void handleIntent(Intent intent) {
    super.handleIntent(intent);
    // Get Data here
    Log.d(TAG, "intent.."+intent.getExtras());
    Intent intent1=new Intent(this,MainActivity.class);
    intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent1);
}

注意:某些设备(例如华硕的手机管理器)可能会在通知到达时拒绝启动应用程序的接收器.在这种情况下,请提供适当的权限.

Note : Some devices (Eg; ASUS's Mobile Manager) may reject to start Application's receiver while , Notification arrives.In that case please provide appropriate permissions.

这篇关于当应用程序未运行 (iphone/android) 时,在远程触发器上创建一个(重复的高音)警报,就像“查找我的 iPhone"一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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