做优惠网站多少钱/凡科建站怎么导出网页
官方文档:
向后台应用发送测试消息 | Firebase Cloud Messaging
1、根级(项目级)Gradlegradle的dependencies中添加:
dependencies {...// Add the dependency for the Google services Gradle pluginclasspath 'com.google.gms:google-services:4.3.10'}
2、模块(应用级)Gradle 中添加 Google 服务插件:
plugins {id 'com.android.application'// Add the Google services Gradle pluginid 'com.google.gms.google-services'...
}
或者
apply {plugin 'com.android.application'// Add the Google services Gradle pluginplugin "com.google.gms.google-services"
}
添加 Firebase Cloud Messaging Android 库的依赖项:(按官方的应该也是可以的)
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))implementation("com.google.firebase:firebase-analytics-ktx")
// implementation("com.google.firebase:firebase-auth-ktx")implementation("com.google.firebase:firebase-firestore-ktx")implementation("com.google.firebase:firebase-messaging")// Firebase Cloud Messaging (Kotlin)implementation("com.google.firebase:firebase-messaging-ktx")
3、消息接收
AndroidManifest.xml中添加,接受类
<serviceandroid:name=".BillionFirebaseMessagingService"android:exported="true"><intent-filter><action android:name="com.google.firebase.MESSAGING_EVENT" /></intent-filter></service>
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;import com.game.base.sdk.BaseSDK;
import com.game.base.sdk.Events;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson;import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;import java.util.Locale;
import java.util.Map;
import java.util.jar.JarException;
import java.lang.Boolean;import game.billion.block.blast.bbb.MainActivity;
import game.billion.block.blast.bbb.R;
import kotlin.Pair;public class BillionFirebaseMessagingService extends FirebaseMessagingService {private String channelID = "game.puzzle.block.billion.pro.notification";private String channelName = "messageName";int notifyID = 101010;//监控令牌的生成@Overridepublic void onNewToken(@NonNull String token) {super.onNewToken(token);Log.d("BillionFirebaseMessagingService", "onNewToken:"+token);}//监控推送的消息@Overridepublic void onMessageReceived(@NonNull RemoteMessage mge) {super.onMessageReceived(mge);Log.d("BillionFirebaseMessagingService", "From:"+mge.getFrom());Log.d("BillionFirebaseMessagingService", "data:"+mge.getData());Map<String,String> dt = mge.getData();String ti =dt.get("title"); //标题(多语言),JSON字符串try {if (ti != null && !ti.isEmpty()){JSONObject json =new JSONObject(ti);String language = Locale.getDefault().getLanguage();if (language=="pt"){//获取巴西语String resTitle = json.getString("pt");if (resTitle != null && !resTitle.isEmpty()){//显示通知addNotification(resTitle);}}else {String resTitle = json.getString("en");if (resTitle != null && !resTitle.isEmpty()){//显示通知addNotification(resTitle);}}}} catch (JSONException e) {}String mgeId = mge.getMessageId();String intent =dt.get("intent");String strId =dt.get("sid");Pair<String, String>[] params = new Pair[3];params[0] = new Pair<>("message_id", mgeId);params[1] = new Pair<>("type", intent);params[2] = new Pair<>("sid", strId);Events.push("100410", params);}//添加提示private void addNotification(String resTitle ){if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);NotificationChannel nc=newNotificationChannel(channelID, channelName);if (nc!=null){if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {managerCompat.createNotificationChannel(nc);}}Intent nfIntent = new Intent(this, MainActivity.class);PendingIntent pendingIntent ;if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {pendingIntent=PendingIntent.getActivity(this, 0, nfIntent, PendingIntent.FLAG_IMMUTABLE);} else {pendingIntent=PendingIntent.getActivity(this, 0, nfIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);}NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelID);builder.setContentIntent(pendingIntent); // 设置PendingIntentbuilder.setSmallIcon(R.drawable.notification); // 设置状态栏内的小图标builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);builder.setStyle(new NotificationCompat.BigTextStyle());builder.setContentTitle(getString(R.string.app_name));builder.setContentText(resTitle);builder.setWhen(System.currentTimeMillis());builder.setAutoCancel(true);managerCompat.notify(notifyID, builder.build());}}private NotificationChannel newNotificationChannel(String cId, String cName){if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {NotificationChannel channel =new NotificationChannel(cId, channelName, NotificationManager.IMPORTANCE_HIGH);channel.setSound(null, null);channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);return channel;}return null;}
}
4、测试(google-services.json 记得放应用级中)
a、获取tokn
//在firebase中检查google版本是否有问题GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this).addOnCompleteListener(new OnCompleteListener<Void>() {@Overridepublic void onComplete(@NonNull Task<Void> task) {if (task.isSuccessful()) {Log.d("Firebase", "onComplete: Play services OKAY");//firebase 推送 (FCM)获取token(FCM令牌)FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() {@Overridepublic void onComplete(@NonNull Task<String> task) {if (!task.isSuccessful()){Log.w("Firebase", "Fetching FCM registration token failed", task.getException());return;}// Get new FCM registration tokenString ss= task.getResult();Log.d("Firebase", "onComplete:token getResult "+ss);}});} else {// Show the user some UI explaining that the needed version// of Play services Could not be installed and the app can't run.}}});
b、用tokn就能对固定手机发送消息
相关文章:

Android Firebase (FCM)推送接入
官方文档: 向后台应用发送测试消息 | Firebase Cloud Messaging 1、根级(项目级)Gradlegradle的dependencies中添加: dependencies {...// Add the dependency for the Google services Gradle pluginclasspath com.google.gm…...

Neo4j恢复
主要记录windows环境下从备份文件中恢复Neo4j, Linux环境同理 备份在上一篇中有介绍,参考: Neo4j备份-CSDN博客 误删数据 为了模拟误删除场景,我们查询Person,并模拟误操作将其进行删除; match(p:Person) return …...

ZZULIOJ 1114: 逆序
题目描述 输入n(1<n<10)和n个整数,逆序输出这n个整数。 输入 输入n(1<n<10),然后输入n个整数。 输出 逆序输出这n个整数,每个整数占4列,右对齐。 样例输入 Copy …...

Linux前后端项目部署
目录 1.jdk&tomcat安装 配置并且测试jdk安装 修改tomcat 配置文件 登入tomcat 发布 安装mysql 导入sql数据 发布项目war包 redis安装 nginx安装 配置nginx域名映射 部署前端项目 centos 7的服务安装 安装jdk 安装tomcat 安装Mysql 安装redis 安装nginx 前后…...

GPT-4与DALL·E 3:跨界融合,开启绘画与文本的新纪元
在人工智能的发展浪潮中,MidTool(https://www.aimidtool.com/)的GPT-4与DALLE 3的集成代表了一个跨越式的进步。这一集成不仅仅是技术的结合,更是艺术与文字的完美融合,它为创意产业带来了革命性的变革。本文将探讨GPT…...

聊聊PowerJob的Alarmable
序 本文主要研究一下PowerJob的Alarmable Alarmable tech/powerjob/server/extension/Alarmable.java public interface Alarmable {void onFailed(Alarm alarm, List<UserInfoDO> targetUserList); }Alarmable接口定义了onFailed方法,其入参为alarm及tar…...

系列三十五、获取Excel中的总记录数
一、获取Excel中的总记录数 1.1、概述 使用EasyExcel开发进行文件上传时,通常会碰到一个问题,那就是Excel中的记录数太多,使用传统的方案进行文件上传,很容易就超时了,这时可以通过对用户上传的Excel中的数量进行限制…...

VMware workstation安装debian-12.1.0虚拟机并配置网络
VMware workstation安装debian-12.1.0虚拟机并配置网络 Debian 是一个完全自由的操作系统!Debian 有一个由普罗大众组成的社区!该文档适用于在VMware workstation平台安装debian-12.1.0虚拟机。 1.安装准备 1.1安装平台 Windows 11 1.2软件信息 软…...

centos下系统全局检测工具dstat使用
目录 一:没有需要安装 二:dstat命令参数 三、监测界面各参数含义(部分) 四、dstat的高级用法 一:没有需要安装 yum install dstat 二:dstat命令参数 有默认选项,执行dstat命令不加任何参数…...

无人机群ros通信
单架无人机与地面站通信 在一个局域网内获取无人机的机载电脑ip 通过地面站ssh到机载电脑,实现通信 多架无人机与地面站通信 在ROS基础上,配置主机和从机,实现主机和从机的话题联通 配置hosts 在主机和从机的/etc/hosts文件中,…...

LeetCode刷题:142. 环形链表 II
题目: 是否独立解决:否,参考了解题思路解决问题,思考了用快慢指针,栈,统计链表数量定位尾巴节点(因为是环形链表所以是死循环,链表数量用while循环统计不出来)都没解决 解…...

Laravel 使用rdkafka_laravel详细教程(实操避坑)
一、选择rdkafka 首先要看版本兼容问题,我的是Laravel5.6,PHP是7.3.13,所以需要下载兼容此的rdkafka,去 Packagist 搜索 kafka ,我用的是 enqueue/rdkafka选择里面0.10.5版本, 二、安装rdkafka 在 Larav…...

439 - Knight Moves (UVA)
题目链接如下: Online Judge UVA439 骑士的移动 - 锦依卫议事堂 - 洛谷博客 这里有好几个特别厉害的解法...先存着慢慢看。 我的代码如下: #include <iostream> #include <deque> #include <string> // #define debugstruct node{…...

数据结构(c)冒泡排序
本文除了最下面的代码是我写的,其余是网上抄写的。 冒泡排序 什么是冒泡排序? 冒泡排序(Bubble Sort)是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交…...

并发编程之并发容器
目录 并发容器 CopyOnWriteArrayList 应用场景 常用方法 读多写少场景使用CopyOnWriteArrayList举例 CopyOnWriteArrayList原理 CopyOnWriteArrayList 的缺陷 扩展迭代器fail-fast与fail-safe机制 ConcurrentHashMap 应用场景 常用方法 并发场景下线程安全举例 Con…...

K8s---存储卷(动态pv和pvc)
当我要发布pvc可以生成pv,还可以共享服务器上直接生成挂载目录。pvc直接绑定pv。 动态pv需要两个组件 1、卷插件:k8s本生支持的动态pv创建不包括nfs,需要声明和安装一个外部插件 Provisioner: 存储分配器。动态创建pv,然后根据pvc的请求自动…...

JS判断对象是否为空对象的几种方法
通过JSON自带的stringify()方法判断 function isEmptyObj(obj) {return JSON.stringify(obj) {} } console.log(对象是否为空:, isEmptyObj({}))for in 循环判断 function isEmptyObj(obj) {for(let item in obj) {return true}return false } console.log(对…...

算法通关村第十五关—用4KB内存寻找重复元素(青铜)
用4KB内存寻找重复元素 用4KB内存寻找重复元素 题目要求:给定一个数组,包含从1到N的整数,N最大为32000,数组可能还有重复值,且N的取值不定,若只有4KB的内存可用,该如何打印数组中所有重复元素。…...

【PHP】判断字符串是否是有效的base64编码
目录 1.检测长度: 2.检查字符集: 3.判断是否能正常解码 在PHP中,判断一个字符串是否是有效的Base64编码,可以通过以下几种方法: 1.检测长度: Base64编码的字符串长度必须是4的倍数(对于标准…...

鼎盛合|测量精度SOC芯片开发中的技术问题整理
SOC芯片近几年的发展势头迅猛,许多行业中俱可见其身影。SOC芯片并不是传统意义上的芯片,它是一个由多种功能集成的一个芯片。SOC芯片自身在出厂时便带有部分程序,是为了方便设计开发而针对某些行业设计的特定功能。如芯海的SOC芯片大多数则是…...

sql | 学生参加各科考试次数
学生表: Students------------------------ | Column Name | Type | ------------------------ | student_id | int | | student_name | varchar | ------------------------ 在 SQL 中,主键为 student_id(学生ID)。 该表内的每…...

uniapp(vue2)+VoerkaI18n多语言
今天我学习了VoerkaI18n国际化插件,它是一个适用于Javascript/Vue/React/Solid/ReactNative的国际化全流程解决方案。VoerkaI18n可以帮助我们轻松地实现应用程序的多语言支持,使得应用程序可以适应不同的语言环境。 比较吸引我的是集成自动翻译,t(“中华…...

C51--测速小车
测速小车: 测速模块: 用途: 广泛用于电机转速检测,脉冲计数,位置限位等。 高低电平: 有遮挡,输出高电平; 无遮挡,输出低电平。 接线: VCC——正极 GND——接…...

ORACLE报错:ORA-04091 表XXX发生了变化,触发器/函数不能读它
ORACLE报错:ORA-04091 表发XXX生了变化,触发器/函数不能读它 问题描述问题分析解决办法拓展:自治事务的特点 问题描述 在开发校验函数FUNCTION的时候,用数据跑批测试的时候报错。经排查这个校验函数FUNCTION的被一个存储过程中的update语句调…...

Arm LDM和STM的寻址方式
A32指令集中包含多数据传输指令LDM和STM,也就是单条指令可以传输多个寄存器的值与内存交互,这对于数据块传输以及寄存器的压入栈很有帮助。LDM和STM指令可分别用于实现堆栈的pop和push操作。对于堆栈操作,基寄存器通常是堆栈指针(SP)。 LDM和…...

网络技术基础入门全套实验-厦门微思网络CCNA实验手册
知识改变命运,技术就是要分享,有问题随时联系,免费答疑,欢迎联系! 微思简介(https://www.xmws.cn) 微思成立于2002年,是一个诚信敬业、积极向上、充满活力、专注技术服务的企业。 微思获得了八…...

【已解决】C语言实现多线程检索数据
本博文源于笔者正在学习的c语言。学习如何用多线程进行检索数据。这里以检索一个数组的数据为例,给出代码,并分析如何进行线程通信,如果检索到,其余就别检索了。 文章目录 问题来源问题解决方案代码实现效果总结 问题来源 想要用…...

用LM Studio:2分钟在本地免费部署大语言模型,替代ChatGPT
你想在本地使用类似ChatGPT 的大语言模型么?LM Studio 可以帮你2分钟实现ChatGPT的功能,而且可以切换很多不同类型的大语言模型,同时支持在Windows和MAC上的PC端部署。 LM Studio是一款面向开发者的友好工具,特别适合那些想要探索…...
C语言经典算法之直接排序算法
目录 前言 一、代码实现 二、时空复杂度 时间复杂度: 空间复杂度: 前言 建议:1.学习算法最重要的是理解算法的每一步,而不是记住算法。 2.建议读者学习算法的时候,自己手动一步一步地运行算法。 tips:希尔排序算…...

前端开发vscode 常用插件记录
通用插件: 一、live Server 主要作用是提供一个本地开发服务器,以便实时预览和调试网页应用程序。 二、css peek 它的主要作用是帮助开发人员更轻松地查找和导航CSS样式表中的类、ID、选择器和样式定义(鼠标移动到css样式名即可查看样式&…...