ThomasH.Allen
ThomasH.Allen

Reputation: 123

How to push notification remotely with React-Native-Push-Notification?

I am new at mobile app developing, and i have been looking into push notification and , i understand that you have local notification, static on the device and remote notification, send from a notification server (which is not the application server), i am trying to use this library, quite a popular one for doing push notification:

https://github.com/zo0r/react-native-push-notification

I can understand how to set it up in the react native project and use local notification since i found a specific tutorial for it, but the tutorial only show how to use the local notification.

I have been searching for more documents on how to use this library for remote notification step by step, from setting up the notification server to use it in the react native app, but they are all so vague explanations or use different tools.

Upvotes: 2

Views: 4301

Answers (3)

ecem
ecem

Reputation: 11

You can also use netmera service like here: https://github.com/Netmera/Netmera-React-Native-Example

Netmera can also be used with firebase, all you have to do is use the method below:

messaging()
   .getToken(firebase.app().options.messagingSenderId)
   .then(pushToken => {
       Netmera.onNetmeraNewToken(pushToken)
});

messaging().onMessage(async remoteMessage => {
   if (Netmera.isNetmeraRemoteMessage(remoteMessage.data)) {
       Netmera.onNetmeraFirebasePushMessageReceived(remoteMessage.from, remoteMessage.data)
   }
});

messaging().setBackgroundMessageHandler(async (remoteMessage) => {
    if (Netmera.isNetmeraRemoteMessage(remoteMessage.data)) {
        Netmera.onNetmeraFirebasePushMessageReceived(remoteMessage.from, remoteMessage.data)
    }
});

Upvotes: 0

Rahul Shakya
Rahul Shakya

Reputation: 1425

Firstly go to rnfirebase and follow the process.. You will have do stuffs like yarn add (app/messaging), pod install, some changes in podfile, configure appDelegate.m firapp, notification etc.. and then mostly the problem comes with developer.apple.com

YES, you compulsory require developer account

Create identifier with push notification checked -> Using key chain generate => Certificate Assistat > Request A Certificate from Certificate Authority to create certificate in below steps.

-> Press Configure on push notification and create certificate which will create apple push services for both development and production for release and debug and download and click it on add on keychain

-> Generate .p12 file of both certificate release and production using Keychain all you have to do it click in the certificate you just add on keychain you can verify with expiry date if is confusing... then right click export to create .p12 file put password that you wont forget

-> Put your .p12 file on Firebase Cloud Messaging under project settings > cloud messaging (Here you will need the password you set)

-> go to user developer account and create profiles both IOS development and App Store and please select the required certificate while creating AppStore Production profile

-> Now run app using development profile on Xcode and Archive using production/distribution profile

-> Test notification using Cloud Messaging Notification tools provided by firebase if it work it works if it don't check then above step throughly

Upvotes: 0

akshay gore
akshay gore

Reputation: 1006

You can use services such as oneSignal & FCM. Here are some libraries for push notification

https://github.com/geektimecoil/react-native-onesignal (one signal)

Tutorial : https://medium.com/differential/react-native-push-notifications-with-onesignal-9db6a7d75e1e

You can use the below library for FCM if you need any other firebase services such as authentication, dynamic links etc.. go for this

https://github.com/invertase/react-native-firebase (fcm)

If you just need only push notification services, you can use

https://github.com/evollu/react-native-fcm

Some helpful blogs for the integration

https://medium.com/react-native-training/react-native-push-notifications-with-amazon-pinpoint-ios-b2efa89ced32

https://medium.com/differential/how-to-setup-push-notifications-in-react-native-ios-android-30ea0131355e

Upvotes: 5

Related Questions