ExpoのNotifications
ExpoのPush通知
Push通知
expo-notificationsを付く
docs
overviewのdocs
ライブラリ云々以前のセットアップの話
Expo — Push notification tool
ここでプッシュ通知を実際に送ってデバッグできる
debug方法
Simulator上では機能しないので実機を使うこと
Simulator上ではPermissionが常にundeterminedになる
buildしなくても動く
普通にQRコードから実機で動かした状態で、iPhoneの画面を消す
その状態でこれで通知を送る
実装の概要
clientとbackendの両方で実装が必要
clientでやること
userにpush通知の許可を得る
userのExpoPushTokenを得てbackendに飛ばす
subscribeする処理
backendでやること
ExpoPushTokenをuserと紐付けてDBに保存しておく
実際にpush通知を送る用のAPIの実装
#WIP
setup
frontend
Push Notifications Setup - Expo Documentation
2つやることがある
userにpush通知の許可を得る
userのExpoPushTokenを得る
mailでいうmail addressのようなもの
backend
https://docs.expo.dev/push-notifications/sending-notifications/
別途作業が必要?
But when using EAS Build or the bare workflow, you'll need to use the expo credentials:manager command to upload your push notification credentials to Expo's servers. You can find more detailed instructions here. ref
FCM, APN
https://docs.expo.dev/push-notifications/sending-notifications-custom/
https://docs.expo.dev/push-notifications/receiving-notifications/
https://docs.expo.dev/push-notifications/using-fcm/
#??
FCMってなに?
APNってなに?
アプリ起動時のプッシュ通知を操作するためには
Notifications.addNotificationReceivedListenerらへんを使う
docsの上部の方にサンプルコードがある
例えば、アプリを触っているときに通知が来たら、ボトムタブのマイページのアイコンに数字アイコンを表示する、など
Androidはどういう仕組なのか
普通にExpoを使っていてもFCMの設定が必要なのか
Firebase Cloud Messaging
const deviceToken = await Notifications.getExpoPushTokenAsync()が動かない
けっこう詰まっていたが何もしてないのに直った...mrsekut.icon
alert(deviceToken.data);で見るとか
このissueとほぼ同じ現象なのでここを見たら解決するかも
FCMの設定が必要(iosなので関係なさそうだけども)
そもそもビルドしないと動かないもの?
expo-notificationはexpoのversionが3.8以上でないと動かない
Expo Notifications: Invariant Violation: Native module cannot be null.みたいなエラーが出る