Android Google的firebase云消息的使用。

相关链接及参考:Google的firebase使用(Android)(很详细的案例)
Github上firebase源码(messaging文件夹即是云消息的源码)
云消息API文档(官方文档)
下面介绍具体实现。
首先,拥有goole帐号并在firebase控制台注册APP。按照相关步骤来。
这里写图片描述
将源码中的三个类复制粘贴。
在这里可以实现打开APP让推送的内容显示remoteMessage.getNotification().getBody()

        // Check if message contains a notification payload. 检查消息是否包含通知有效载荷。
        if (remoteMessage.getNotification() != null) {
            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
            Log.i("AAAAA", "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }

和获得token值FirebaseInstanceId.getInstance().getToken();

          String token = FirebaseInstanceId.getInstance().getToken();

                // Log and toast
                String msg = getString(R.string.msg_token_fmt, token);
                Log.d(TAG, msg);
                Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();

云消息的小图标即应用的图标。
这里发消息
源码下载

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值