惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
Cisco Talos Blog
Cisco Talos Blog
Hacker News: Ask HN
Hacker News: Ask HN
Simon Willison's Weblog
Simon Willison's Weblog
W
WeLiveSecurity
H
Hacker News: Front Page
L
LINUX DO - 热门话题
T
Tor Project blog
N
News | PayPal Newsroom
S
Secure Thoughts
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
AWS News Blog
AWS News Blog
Security Latest
Security Latest
MyScale Blog
MyScale Blog
Webroot Blog
Webroot Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
腾讯CDC
T
Tailwind CSS Blog
SecWiki News
SecWiki News
博客园 - 司徒正美
Microsoft Azure Blog
Microsoft Azure Blog
P
Palo Alto Networks Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
GbyAI
GbyAI
C
Check Point Blog
博客园_首页
PCI Perspectives
PCI Perspectives
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 数据收集原理分析 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 几种方法 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 check the export on the very top of this document so we can use $do mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 延伸 -- 关于前端路由 xdebug 3 和 2 的区别
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

Firebase Cloud Messaging (FCM) 是一种跨平台(安卓,IOS,Web)消息传递解决方案,且无需任何费用。

最近用cordova开发app,客户希望用firebase带的消息推送功能,国内我们知道有激光推送,leancloud,而国外firebase非常出名。

cordova使用firebase需要注意以下几点:

  • 因为firebase已被google收购,国内手机设备无法接收来自firebase的推送,除非开代理,要打开的端口和主机名见官方文档

  • 手机上的app运行状态分前台和后台

    • 前台运行时可以接收到消息推送,但是不会有消息栏的提醒(这是手机的默认行为),对于安卓,如果要在前台显示推送,推荐使用cordova-plugin-local-notification 插件
    • 后台运行或关闭时,手机收到推送会显示消息栏,如果用户点击通知,app会显示在前台,通知内容会被JS回调接收。如果不点击或关闭,通知将一直存在。
  • 我们项目中使用的是cordova-plugin-firebasex ,有个bug,手机息屏接收消息很快,亮屏app后台运行接收不稳定。

  • 关于通知权限,对于安卓,不需要授权,但是对于apple,需要调用请求授权方法,如我们用到的cordova-plugin-firebasex插件需要调用提供的grantpermission方法。

  • 使用安卓模拟器时记得选用带GooglePlay标志的版本,然后需要在更多设置里更新GooglePlay的版本,并在虚拟机内部做一下接入点代理,记得勾选一下梯子的允许来自局域网的访问。

  • FCM发送推送分三种类型:

    • 按设备ID(针对性强,可以只发给某几台设备),需要传device token
    • topic主题,比如定义一个名为ad的topic,只有订阅这个topic的设备才能接收到通知
    • 按target目标,这应该是firebase的特色,你可以针对某平台(ios或android),某个国家,某目标人群等统计相关参数发推送,很灵活。但是需要创建firebase创建项目时候开启google analysis

  • APN(Apple Push Notification),不像安卓生态那么混乱,苹果生态中所有通知都走APN,大致流程:firebase通知APN,APN通知apple设备客户端。技术文档, firebase连APN需要我们在apple后台生成验权文件,就是P8或P12,后面会讲。

  • 对于安卓,确保在firebase项目设置中生成了google-services.json文件,对于ios,要生成GoogleService-Info.plist文件,生成文件在放到cordova项目根目录,对于ios,还需要到苹果开发者后后台生成p8或p12文件并上传到firebase项目ios集成页面中

强烈建议生成P8认证文件,P12文件有很多缺点: 流程繁琐,区分开发和正式环境,还有有效期。P8和P12文件生成流程参见:iOS 推送设置指南

  • 消息推送内容可以带emoji

集成了如何测试? ​

如果是用的Cordova集成消息推送,建议先运行这个插件的demo项目 安卓手机模拟器可以收到推送消息,苹果的必须真机,收到推送消息的前提的运行获取FCM IDFCM token成功(记得开代理,或者保证能访问google)

如何使用命令行发送消息 ​

可以直接用curl命令调用https://fcm.googleapis.com/v1/projects/${project-id}/messages:send发送消息 ${project-id} 替换成firebase中project setting页面中生成的

bash

curl -X POST -H "Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA" -H "Content-Type: application/json" -d '{
  "message": {
    "topic" : "my-topic",
    "notification": {
      "body": "This is a Firebase Cloud Messaging Topic Message!",
      "title": "FCM Message"
    }
  }
}' https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

参考 ​

https://juejin.cn/post/6844904153274155022

https://github.com/katzer/cordova-plugin-local-notifications#readme

https://www.npmjs.com/package/cordova-plugin-fcm-with-dependecy-updated

https://developer.apple.com/documentation/usernotifications