Configure expo notifications for push notifications - react-native

I have 2 apps and I implemented expo push notification and everything was fine, but in the other one it asked me for the experienceid as a prop to Notifications.getExpoPushTokenAsync({
experienceId: "#name/slug,
});
and when trying to send a notification it gives me this error: InvalidCredentials: Unable to retrieve the FCM server key for the recipient's app. Make sure you have provided a server key as directed by the Expo FCM documentation.
I dont want to use FCM, i want to use expo push api.
Can you help me?

The Expo Push API uses FCM for Android, and while it's not necessary to configure it for Expo Go (this is done already for the Expo Go app), when you deploy your standalone app you will need to have it configured for FCM. More information here: https://docs.expo.dev/push-notifications/using-fcm/

Related

How to use FCM (Firebase Cloud Messaging) while making build of expo react native app through eas cli

I had expo sdk less than sdk 45 in my expo react native app which previously used expo cli. For using FCM, I used to write expo push:android:upload --api-key , in which your token means server key. But now, my app has been converted to eas cli and I can't find the command or procedure to use FCM for notifications in my app anywhere not even in expo documentation. I previously used to follow this guide
enter link description here
Run eas credentials, select Android, then Push Notifications: Manage your FCM Api Key, and then choose the appropriate option to set up the key.
docs...
OR
Go to https://expo.dev/
Select a project
Go to credentials
Click on the application ID
In the Service Credentials section, add FCM Server Key

Will an Android app only receive push notifications is the app was downloaded from the Google Play Store? (React Native Expo)

I'm using Expo push notifications. Push notifications work fine in Expo Go and for apps on published to the Google Play store. But when I create an APK file and download it directly onto my Android phone, NOT through the Google Play store, the push notifications I send are not received.
Will push notifications only work for apps published to the Google Play store? Or is there a way to receive push notifications for apps downloaded directly onto an Android phone without being published to the Google Play store?
Depending on your android version and rom you have to open the app setting's (for me long press app icon).
Select settings
Choose notifications
Enable notification for this app
I forgot to import { Platform } from 'react-native'.
Also, I needed to upload Android server api key credentials which can be found in Firebase Console in your project settings under Cloud Messaging. Here is how to upload the server api key credentials in the terminal:
expo push:android:upload --api-key <your-token-here>
Documentation can be found here under "Uploading Server Credentials": https://docs.expo.dev/push-notifications/using-fcm/

FCM: Mismatched Sender Id when trying to send notification to Expo app

I have a backend that send fcm to web app and expo apps. Double checked all the credentials. But still unable to get it work. Both of the credentials are under same project. Backend is using firebase admin, with service account. Front end is using google-services.json. Anyone encountered this?
Found out that the device token from expo-notification can only be used on standalone build. But not in expo-client during development.
https://forums.expo.io/t/using-fcm-as-push-notification-with-expo-client/42402/2?u=cyee
This is the copy paste comment by expo team.
Hi! If you want to send notifications directly through FCM, and not
through the Expo notifications service, you’ll have to test in a
standalone app (as in, an app you built with expo build:android). This
is because you don’t have the push credentials for the Expo client
app, only we do :slight_smile:
If you want to test in the Expo client app, then you can do that with
Expo’s notifications, which you can read more about here-
https://docs.expo.io/push-notifications/overview/

How can I make a react native application with push notifications and an API

I am building a new application in React Native and I built an API for the back-end.
I want to build in a push notification in the app when there is a new entry delivered by the API. I saw a framework that background fetches an API route and then shows a push notification but this only applies ones every 15 minutes. Other push notifications tutorials I see only work with a firebase database and I need it to work with my API.
Is somebody known with combining rest api's with push notifications in react native, that can help me?
Greetings,
Laurens
step 1:- first you need to add react-native-firebase, messaging in your react-native project for receiving push notification.
link to add react-native-firebase
step 2 :- check your application setup using firebase console's
Cloud Messaging service.
https://console.firebase.google.com/project/fir-demo-f375c/notification
if your application setup is perfect you will get push notification in device from firebase console's Cloud Messaging service.
step 3:- need to add server side code to fire push notification from server,
when your api hites to using server language like PHP.
for more detail in step 3 follow
https://firebase.google.com/docs/cloud-messaging/server#implementing-http-connection-server-protocol

React Native Push Notifications doesn't receive notification

I have a React Native app (testing on iOS) and am trying to incorporate Push notifications. I am using the following module:https://www.npmjs.com/package/react-native-firebase-push-notifications.
I tried running example app code and am able to obtain
a (1) message token and (2) successfully obtain permissions from my device.
I am trying to send a test notification from Firebase and am using my device's token. However, nothing happens upon triggering a test notification. Any tips? I believe I followed the key upload instructions correctly (https://firebase.google.com/docs/cloud-messaging/ios/certs)
I hope you have uploaded pem/p8 file on firebase console at "Cloud Messaging" in Project settings. Check this image
I figured it out! Although I thought I had done this in the past, I did not have Remote notification enabled in background modes, nor did I have Push notifications checked in the Signing & Capabilities section of project setting on Xcode. Thank you!