当App未运行时(iphone / android)就像Find My iPhone一样,在远程触发器上创建一个(重复的高音)警报 [英] Create an (repetitive high pitch) Alarm on a remote trigger when App is not running (iphone/android) just like Find My 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.
向用户显示内容(Alaram / UI,如调用屏幕),以便在接收FireBase通知时启动自定义Activity.Override handleIntent
来自 FirebaseMessagingService
。所以你可以从被杀/空闲的应用程序接收数据。
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);
}
注意:某些设备(例如; ASUS的移动管理器)可能拒绝启动应用程序的接收器,而通知到达。在这种情况下,请提供适当的权限。
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.
这篇关于当App未运行时(iphone / android)就像Find My iPhone一样,在远程触发器上创建一个(重复的高音)警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!