2017-05-04 3 views
0

アンドロイドアプリケーションを作成し、ファイアベースサーバで特定の人に通知します。お願い助けて。アンドロイドアプリでファイアベースコンソールを呼び出す方法と、特定のユーザアプリ(デバイスファイヤーベースデバイス)で通知する方法

My code is: 

public class MyFirebaseMessagingService extends FirebaseMessagingService { 
    private static final String TAG="MyMessageservice"; 
    RemoteMessage remoteMessage; 
    @Override 
    public void onMessageReceived(RemoteMessage remoteMessage){ 
     String title=remoteMessage.getNotification().getTitle(); 
     String message=remoteMessage.getNotification().getBody(); 
     String lick_action=remoteMessage.getNotification().getClickAction(); 
     Intent intent=new Intent(click_action); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); 
     Uri notificattionSound= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
     NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(this); 
     notificationbuilder.setContentTitle(title); 
     notificationbuilder.setContentText(message); 
     notificationbuilder.setAutoCancel(true); 
     notificationbuilder.setSound(notificattionSound); 
     notificationbuilder.setSmallIcon(R.drawable.ic_launcher); 
     notificationbuilder.setContentIntent(pendingIntent); 
     notificationbuilder.setAutoCancel(true); 
     NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     notificationManager.notify(0, notificationbuilder.build()); 
    } 
+0

エラーが発生しましたか? –

+0

いいえ、デバイスからデバイスへの通知方法 – Anbu

+0

可能でしょうか? – Anbu

答えて

0

あなたが特定のデバイスに通知を送信したい場合、私はあなたOneSignalを示唆しています。実装が非常に簡単で無料です。

このソリューションの利点は、特定のユーザーのみに通知を送信できるということではなく、ユーザーグループに送信することもできます。また、これを達成するためにサードパーティのサーバーは必要ありません。

これをご覧ください。video

希望します。

+0

通知の送信に関する問題を解決しましたか? –

関連する問題