APPCHOBO
SYSTEM BOOTING...
v0.1.bit · firebase build · 富士 ed.
LV14
HP87/100
MP42/80
EXP2,840
1,240 G
앱초보의 모험
◀ 프롬프트 창고
#앱별 실전 패턴 · claude-code

[prayer_app] 푸시 알림 — 새 기도제목 올라옴

그룹에 새 기도제목이 올라오면 멤버에게 푸시 알림.

#prayer-app#fcm#push-notification
그룹에 새 기도제목이 올라오면 멤버에게 푸시 알림. 구현: 1. **Cloud Function (새 기도제목 생성 시 트리거):** ```typescript exports.notifyNewPrayer = functions.firestore .document('prayers/{prayerId}') .onCreate(async (snap, context) => { const prayer = snap.data(); const groupId = prayer.groupId; // 그룹 멤버 조회 const groupDoc = await db.collection('groups').doc(groupId).get(); const members = groupDoc.data().members || []; // 각 멤버의 FCM 토큰 조회 const tokenSnapshots = await db .collection('users') .where('uid', 'in', members) .get(); const tokens = []; tokenSnapshots.forEach((doc) => { if (doc.data().fcmToken) tokens.push(doc.data().fcmToken); }); // 푸시 알림 전송 const message = { notification: { title: '새 기도제목', body: prayer.title, }, webpush: { fcmOptions: { link: `/prayer/${context.params.prayerId}` }, }, }; return admin.messaging().sendMulticast({ tokens, notification: message.notification, }); }); ``` 2. **클라이언트에서 FCM 토큰 저장:** ```dart Future<void> saveFCMToken() async { final token = await FirebaseMessaging.instance.getToken(); await db.collection('users').doc(currentUserId).update({ 'fcmToken': token, }); } ``` 3. **포어그라운드 알림 처리 (Flutter):** ```dart FirebaseMessaging.onMessage.listen((RemoteMessage message) { final notification = message.notification; showDialog( context: context, builder: (_) => AlertDialog( title: Text(notification?.title ?? ''), content: Text(notification?.body ?? ''), actions: [ TextButton( onPressed: () { Navigator.pop(context); // 기도제목 화면으로 이동 }, child: Text('보기'), ), ], ), ); }); ``` 구현해줄까?
쓰는 법 — 위 칸에 본인 값을 채우면 아래 프롬프트에 바로 반영돼요. 복사 버튼을 누르면 채워진 그대로 클립보드에 담기니까, claude-code(또는 본인이 쓰는 AI)에 붙여넣기만 하면 됩니다. 변수가 없으면 그냥 복사해서 쓰세요.
▼ SPONSORED ▼
프롬프트 하단 광고