push-notification-setup by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill push-notification-setup使用 Firebase Cloud Messaging 和原生平台服务,为 iOS 和 Android 应用程序实现全面的推送通知系统。
最小工作示例:
import messaging from "@react-native-firebase/messaging";
import { Platform } from "react-native";
export async function initializeFirebase() {
try {
if (Platform.OS === "ios") {
const permission = await messaging().requestPermission();
if (permission === messaging.AuthorizationStatus.AUTHORIZED) {
console.log("iOS notification permission granted");
}
}
const token = await messaging().getToken();
console.log("FCM Token:", token);
await saveTokenToBackend(token);
messaging().onTokenRefresh(async (newToken) => {
await saveTokenToBackend(newToken);
});
messaging().onMessage(async (remoteMessage) => {
console.log("Notification received:", remoteMessage);
showLocalNotification(remoteMessage);
});
// ... (完整实现请参阅参考指南)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| Firebase Cloud Messaging 设置 | Firebase Cloud Messaging 设置 |
| 使用 Swift 进行 iOS 原生设置 | 使用 Swift 进行 iOS 原生设置 |
| 使用 Kotlin 进行 Android 设置 | 使用 Kotlin 进行 Android 设置 |
| Flutter 实现 | Flutter 实现 |
每周安装数
176
代码仓库
GitHub 星标数
121
首次出现
2026年1月21日
安全审计
安装于
opencode153
gemini-cli144
codex142
cursor133
claude-code132
github-copilot129
Implement comprehensive push notification systems for iOS and Android applications using Firebase Cloud Messaging and native platform services.
Minimal working example:
import messaging from "@react-native-firebase/messaging";
import { Platform } from "react-native";
export async function initializeFirebase() {
try {
if (Platform.OS === "ios") {
const permission = await messaging().requestPermission();
if (permission === messaging.AuthorizationStatus.AUTHORIZED) {
console.log("iOS notification permission granted");
}
}
const token = await messaging().getToken();
console.log("FCM Token:", token);
await saveTokenToBackend(token);
messaging().onTokenRefresh(async (newToken) => {
await saveTokenToBackend(newToken);
});
messaging().onMessage(async (remoteMessage) => {
console.log("Notification received:", remoteMessage);
showLocalNotification(remoteMessage);
});
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Firebase Cloud Messaging Setup | Firebase Cloud Messaging Setup |
| iOS Native Setup with Swift | iOS Native Setup with Swift |
| Android Setup with Kotlin | Android Setup with Kotlin |
| Flutter Implementation | Flutter Implementation |
Weekly Installs
176
Repository
GitHub Stars
121
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode153
gemini-cli144
codex142
cursor133
claude-code132
github-copilot129
Azure RBAC 权限管理工具:查找最小角色、创建自定义角色与自动化分配
117,000 周安装