• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RemoteMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.firebase.messaging.RemoteMessage的典型用法代码示例。如果您正苦于以下问题:Java RemoteMessage类的具体用法?Java RemoteMessage怎么用?Java RemoteMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RemoteMessage类属于com.google.firebase.messaging包,在下文中一共展示了RemoteMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage message) {
    Map<String, String> data = message.getData();
    String category = data.get("category");
    Log.d(TAG, "notification received");

    if (category == null) {
        Log.w(TAG, "Category is null");
        return;
    }

    switch (category) {
        case "push":
            handlePushNotification(message);
            break;

        case "system":
            handleSystemNotification(message);
            break;

        default:
            Log.w(TAG, "Unknown notification category: " + category);
    }
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:25,代码来源:FcmListenerService.java


示例2: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.d(TAG, "¡Mensaje recibido!");
    //Si es un mensaje del chat de un usuario
    if(remoteMessage.getData()!=null && remoteMessage.getData().containsKey("fcm_token")) {
            String title = remoteMessage.getData().get("title");
            String message = remoteMessage.getData().get("text");
            String username = remoteMessage.getData().get("username");
            String uid = remoteMessage.getData().get("uid");
            String fcmToken = remoteMessage.getData().get("fcm_token");
            //Muestro la notifiación
            sendNotification(title, message, username, uid, fcmToken);
    }else {
        /// Si es de tipo inserción la muestro sino no.
        //Es una nueva notificación de que alguien ha creado algo
        if(remoteMessage.getData().get("accion")!=null &&
                remoteMessage.getData().get("accion").compareTo("insert")==0)
            displayNotification(remoteMessage.getNotification(), remoteMessage.getData());
        //Envío los datos al RecyclerView correspondiente para que se actualice
        addNotificacion(remoteMessage);
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:23,代码来源:MyFirebaseMessagingService.java


示例3: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    Map<String, String> remoteData = remoteMessage.getData();

    EMSLogger.log(MobileEngageTopic.PUSH, "Remote message data %s", remoteData);

    if (MessagingServiceUtils.isMobileEngageMessage(remoteData)) {

        EMSLogger.log(MobileEngageTopic.PUSH, "RemoteMessage is ME message");

        MessagingServiceUtils.cacheNotification(remoteData);

        Notification notification = MessagingServiceUtils.createNotification(
                getApplicationContext(),
                remoteData,
                MobileEngage.getConfig().getOreoConfig());

        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
                .notify((int) System.currentTimeMillis(), notification);
    }
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:24,代码来源:MobileEngageMessagingService.java


示例4: parseCommentOrLike

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
private void parseCommentOrLike(RemoteMessage remoteMessage) {
    String notificationTitle = remoteMessage.getData().get(TITLE_KEY);
    String notificationBody = remoteMessage.getData().get(BODY_KEY);
    String notificationImageUrl = remoteMessage.getData().get(ICON_KEY);
    String postId = remoteMessage.getData().get(POST_ID_KEY);

    Intent backIntent = new Intent(this, MainActivity.class);
    Intent intent = new Intent(this, PostDetailsActivity.class);
    intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, postId);

    Bitmap bitmap = getBitmapFromUrl(notificationImageUrl);

    sendNotification(notificationTitle, notificationBody, bitmap, intent, backIntent);

    LogUtil.logDebug(TAG, "Message Notification Body: " + remoteMessage.getData().get(BODY_KEY));
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例5: displayNotification

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
/**
 * Muestra que ha habido una nueva notificación
 * @param notification
 * @param data
 */
private void displayNotification(RemoteMessage.Notification notification, Map<String, String> data) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra("notificacion","notificacion");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setContentTitle(notification.getTitle())
            .setContentText(notification.getBody())
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setSmallIcon(R.mipmap.ic_launch)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, notificationBuilder.build());
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:27,代码来源:MyFirebaseMessagingService.java


示例6: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getData().size() > 0) {
        Boolean isLongRunningTask = this.isLongRunningTask(remoteMessage.getData());

        if (isLongRunningTask) {
            scheduleJob(remoteMessage.getData());
        } else {
            handleNow(remoteMessage.getData());
        }
    }

    if (remoteMessage.getNotification() != null) {
        sendNotification(remoteMessage.getNotification().getBody());
    }
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例7: parseColor

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Nullable
private Integer parseColor(RemoteMessage.Notification fcmNotification) {
    String notificationColor = fcmNotification.getColor();

    Integer color = null;
    if (notificationColor != null) {
        try {
            color = Color.parseColor(notificationColor);
        } catch (IllegalArgumentException ignore) {
        }
    }
    if (color == null) {
        int colorResId = getResourceIdFromApplicationMetadata("com.google.firebase.messaging.default_notification_color");
        if (colorResId != 0)
            color = ContextCompat.getColor(context, colorResId);
    }
    return color;
}
 
开发者ID:franmontiel,项目名称:FcmNotificationHandler,代码行数:19,代码来源:RemoteMessageToNotificationMapper.java


示例8: handleRemoteMessage

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
private void handleRemoteMessage(RemoteMessage remoteMessage) {
    String receivedActionType = remoteMessage.getData().get(ACTION_TYPE_KEY);
    LogUtil.logDebug(TAG, "Message Notification Action Type: " + receivedActionType);

    switch (receivedActionType) {
        case ACTION_TYPE_NEW_LIKE:
            parseCommentOrLike(remoteMessage);
            break;
        case ACTION_TYPE_NEW_COMMENT:
            parseCommentOrLike(remoteMessage);
            break;
        case ACTION_TYPE_NEW_POST:
            handleNewPostCreatedAction(remoteMessage);
            break;
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例9: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    Intent i = new Intent(this, BottomNavigation.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this,0 , i ,
            PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder nb= new NotificationCompat.Builder(this);
    nb.setContentTitle("FCM Notification");
    nb.setContentText(remoteMessage.getNotification().getBody());
    nb.setAutoCancel(true);
    nb.setSmallIcon(R.mipmap.ic_launcher);
    nb.setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0,nb.build());
}
 
开发者ID:prabhavgupta,项目名称:BookED,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例10: handleMessage

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
private void handleMessage(RemoteMessage remoteMessage) {

        Intent intent = new Intent(this, FirebaseAuth.getInstance().getCurrentUser() == null ? LoginActivity.class:MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent intent1 = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);


        Uri defaultURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this,NotificationCompat.CATEGORY_MESSAGE)
                .setSmallIcon(R.drawable.gdg_notification_icon)
                .setContentTitle(remoteMessage.getNotification().getTitle())
                .setContentText(remoteMessage.getNotification().getBody())
                .setAutoCancel(true)
                .setSound(defaultURI)
                .setContentIntent(intent1);

        NotificationManager manager =  ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
        if (manager != null) {
            manager.notify(23,builder.build());
        }


    }
 
开发者ID:coder3101,项目名称:gdgApp,代码行数:25,代码来源:MessagingService.java


示例11: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
    if (remoteMessage.getData().size() > 0)
    {
        try
        {
            JSONObject json = new JSONObject(remoteMessage.getData().toString());
            sendPushNotification(json);
        }
        catch (Exception e)
        {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }
}
 
开发者ID:ThomasDelaney,项目名称:TapIn,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例12: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    if (remoteMessage.getData().size() > 0) {
        // procesa los datos extra de la notificación
    }

    if (remoteMessage.getNotification() != null) {
        String title = remoteMessage.getNotification().getTitle();
        String message = remoteMessage.getNotification().getBody();
        String clickAction = remoteMessage.getNotification().getClickAction();


        Log.d(TAG, "Title: " + title);
        Log.d(TAG, "Message: " + message);
        Log.d(TAG, "clickAction: " + clickAction);

        sendNotification(title, message, clickAction);
    }

}
 
开发者ID:gothalo,项目名称:Android-2017,代码行数:22,代码来源:FirebaseMessangingService.java


示例13: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    Map<String, String> data = remoteMessage.getData();
    if (data.size() > 0) {
        Intent resultIntent = new Intent(this, MainActivity.class);
        PendingIntent resultPendingIntent = PendingIntent.getActivity(
                this,
                0,
                resultIntent,
                PendingIntent.FLAG_UPDATE_CURRENT
        );
        // 这个是应用在前台的时候出现的通知,应用在后台不会调用,这个并不能把应用拉起来的
        Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Notification n = new NotificationCompat.Builder(this, "channel.fcm")
                .setContentIntent(resultPendingIntent)
                .setContentTitle(data.get("title"))
                .setContentText(data.get("content"))
                .setSound(notificationSound)
                .setSmallIcon(R.drawable.ic_launcher)
                .build();
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        if (notificationManager != null) notificationManager.notify(1, n);
    }
}
 
开发者ID:zhaobao,项目名称:AppsTimeline,代码行数:26,代码来源:MessageService.java


示例14: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

	Log.d(TAG, "FROM:" + remoteMessage.getFrom());

	//Check if the message contains data
	if(remoteMessage.getData().size() > 0) {
		Log.d(TAG, "Message data: " + remoteMessage.getData());
	}

	//Check if the message contains notification
	if(remoteMessage.getNotification() != null) {
		Log.d(TAG, "Message body:" + remoteMessage.getNotification().getBody());
		sendNotification(remoteMessage.getNotification().getBody());
	}
}
 
开发者ID:team-htbr,项目名称:1617PROJ1Bloeddonatie-app,代码行数:17,代码来源:MyFirebaseMessagingService.java


示例15: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    Notification notification = parseNotification(remoteMessage);
    updateNotifDB(notification);

    intent = new Intent(this, NotificationActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent
            .getActivity(getBaseContext(),REQUEST_CODE, intent,PendingIntent.FLAG_ONE_SHOT);
    Uri soundUri = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this,"csi_channel");
    notifBuilder
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(notification.getTitle())
            .setAutoCancel(true)
            .setSound(soundUri)
            .setContentIntent(pendingIntent);
    NotificationManager notifManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notifManager.notify(0,notifBuilder.build());
}
 
开发者ID:CSI-KJSCE,项目名称:CSI-KJSCEOfficial,代码行数:24,代码来源:CSINotificationService.java


示例16: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    Intent intent = new Intent(this , MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this , 0 , intent , PendingIntent.FLAG_ONE_SHOT);


    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_action_notification)
                    .setContentTitle("Cü Yemek")
                    .setContentText("Yemek Listesi Yayımlandı.")
                    .setAutoCancel(true)

                    .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0,notificationBuilder.build());
    vib.vibrate(500);

}
 
开发者ID:yusufcakal,项目名称:CuYemek,代码行数:25,代码来源:MyFirebaseMessagingService.java


示例17: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // ...

    // TODO(developer): Handle FCM messages here.
    // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());
        Map<String, String> data = remoteMessage.getData();

        sendNotification(data.get("message"),data.get("title"));

    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.

}
 
开发者ID:othreecodes,项目名称:WaJeun,代码行数:27,代码来源:PushService.java


示例18: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());

    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        sendNotification(remoteMessage.getNotification().getBody());
    }
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:18,代码来源:MyFirebaseMessagingService.java


示例19: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // ...

    // TODO(developer): Handle FCM messages here.
    // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());
    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
}
 
开发者ID:sivaraj-dev,项目名称:firebase-fcm-sample,代码行数:22,代码来源:MyFirebaseMessagingService.java


示例20: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage != null && remoteMessage.getNotification() != null) {
        Log.d(TAG, "From: " + remoteMessage.getFrom());
        Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "referendum")
                .setLargeIcon(BitmapFactory.decodeResource(
                        getResources(), R.mipmap.ic_launcher))
                .setSmallIcon(R.drawable.ic_notification)
                .setContentTitle(StringsManager.getString("notification_title"))
                .setContentText(remoteMessage.getNotification().getBody());

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (notificationManager != null) {
            notificationManager.notify(1, notificationBuilder.build());
        }
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:20,代码来源:MyFirebaseMessagingService.java



注:本文中的com.google.firebase.messaging.RemoteMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DOMResult类代码示例发布时间:2022-05-20
下一篇:
Java MatcherAssert类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap