как сделать приложение MyFirebaseMessaging for 2 (приложение для водителя и клиента) в одном приложении (приложение для водителя и клиента)? - PullRequest
0 голосов
/ 26 апреля 2018

Я делаю такое приложение, как приложение Uber Clone, но в одном приложении в MyFirebaseMessaging в приложении Uber Clone у него есть 2 драйвера приложения и клиент, а в своем классе MyfirebaseMessaging он создал другой код для драйвера и клиента, например это.

Для приложения драйвера:

public class MyFirebaseMessaging extends FirebaseMessagingService {
 @Override
 public void onMessageReceived(final RemoteMessage remoteMessage) {

  LatLng customer_location = new Gson().fromJson(remoteMessage.getNotification().getBody(), LatLng.class);
  Intent intent = new Intent(getBaseContext(), AppelPassager.class);
  intent.putExtra("lat", customer_location.latitude);
  intent.putExtra("lng", customer_location.longitude);
  intent.putExtra("passager", remoteMessage.getNotification().getTitle());
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
 }
}


Для клиентского приложения:

public class MyFirebaseMessaging_T extends FirebaseMessagingService {
 @Override
 public void onMessageReceived(final RemoteMessage remoteMessage) {
  if (remoteMessage.getNotification().getTitle().equals("Notice")) {
   android.os.Handler handler = new android.os.Handler(getMainLooper());
   handler.post(new Runnable() {
    @Override
    public void run() {
     Toast.makeText(MyFirebaseMessaging_T.this, "" + remoteMessage.getNotification().getBody(), Toast.LENGTH_SHORT).show();
    }
   });

  } else if (remoteMessage.getNotification().getTitle().equals("Arrivé")) {
   showArrivedNotification(remoteMessage.getNotification().getBody());
  }
 }

 private void showArrivedNotification(String body) {
  PendingIntent contentIntent = PendingIntent.getActivity(getBaseContext(), 0, new Intent(), PendingIntent.FLAG_ONE_SHOT);
  NotificationCompat.Builder builder = new NotificationCompat.Builder(getBaseContext());
  builder.setAutoCancel(true).setDefaults(android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.DEFAULT_SOUND).setWhen(System.currentTimeMillis())
   .setSmallIcon(R.mipmap.ic_launcher_round)
   .setContentTitle("Arrivé").setContentText(body).setContentIntent(contentIntent);
  NotificationManager notificationManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.notify(1, builder.build());
 }
}

У меня есть одно приложение. Как я могу опубликовать их в одном классе? Пожалуйста, помогите мне.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...