how to send a message to facebook messenger using url scheme?

前端 未结 3 2024
南笙
南笙 2021-01-25 20:01

Is it possible to send a message to the facebook messenger using url scheme? after searching for schemes I found that messenger opens using fb://messaging/ does anybody know how

3条回答
  •  囚心锁ツ
    2021-01-25 20:57

    you should try this

        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, "Your message");
        sendIntent.setType("text/plain");
        sendIntent.setPackage("com.facebook.orca");
    
        try {
            startActivity(sendIntent);
        } catch (android.content.ActivityNotFoundException ex) {
            ToastHelper.show(this, "Please Install Facebook Messenger");
        }
    

    It will open Facebook Messenger app, select a friend and the message will be send.

提交回复
热议问题