Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

How do I achieve it ?

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.

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

How can I achieve this programmatically on ios and android ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
689 views
Welcome To Ask or Share your Answers For Others

1 Answer

Its possible using FireBase Notification Services with JobService & FirebaseMessagingService.

  • 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.

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

  • 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 Service is System Service & it will be always running.Please have a read.

    Code snippet

    @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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...