React Native SDK Integration
Last updated
Last updated
Quick Steps Guidelines
Step 1. Install React Native
Follow the document below on React Native Installation.
Step 2. iOS Setup
Obtain an Apple Push Notification Certificate from developer.apple.com using your account, and follow the steps for your iOS setup.
Step 3. Android Setup
Create and configure a project on Firebase Developers Console, and follow the steps for your Android setup.
Step 4. Initialize Netmera
Initialize iOS and Android by following the guides below,
Step 5. Request Push Notification Permission
Request push notification authorization by calling the methods in the documentation.
React Native SDK integration completed 👏
Please see the following document on React Native Installation.
For both native sides (Android & iOS) you don't have to include extra Netmera SDK libraries.
To integrate iOS SDK into your project, simply add the following in your Podfile.
We send push notifications using APNS (Apple Push Notification Service). Therefore, you need to obtain an Apple Push Notification Certificate from www.developer.apple.com using your account. Once you have the certificate, you should export it using Keychain Access and add it to the iOS page in the panel's left menu under Developer -> Push Backend.
Important Note on Bundle ID:
Make sure to add the certificate generated with the bundle ID of your project to the panel, and set the bundle ID of your project in the panel as well. Which means, the bundle ID of your project, the bundle ID of the certificate, and the bundle ID set in the panel should all match.
Navigate to iOS folder in your terminal and run the following command.
If you want to use Android alike message sending from iOS to react native please consider shaping your AppDelegate class as following.
For instance, if you trigger [RNNetmeraRCTEventEmitter onPushReceive: @{@"userInfo" : notification.request.content.userInfo}]
from AppDelegate
the following method will be triggered in the react native part.
Please make sure you get the API key value from the relevant panel
YOUR_SDK_API_KEY: You can get the api key from Developers > API > SDK API Key from your Netmera Panel.
Request push notification authorization from user by calling the following method in an appropriate place.
Rich Media Integration for Versions 3.14.4 and higher. Please see the following documentation to see how to integrate iOS Media Push on Media Push.
You can find the latest version details to replace 'X.X.X' on our SDK Versions page linked below.
You need to add these pods outside of your target in Podfile as in the following document.
Navigate to Netmera Panel > Developers > Netmera Onboarding and choose Android.
Click on Android > Start to proceed.
Netmera uses Firebase Cloud Messaging (FCM) to deliver push messages to the Android devices. Therefore, you should create and configure a project on Firebase Developers Console.
At the end of the Firebase configuration, you will have a New Private Key folder of your project. That folder must be uploaded to Developers > Netmera Onboarding > Android > Step 2: Create A Firebase Configuration > FCM Service Account Key section on Netmera Panel.
Firebase Cloud Messaging Configuration
Upload FCM Service Account Key on Netmera Panel
Select the appropriate SDK for your application development framework from the following options: Native Android, Flutter, React Native, Unity. Note: The subsequent instructions on this page are specific to the React Native SDK.
⚠️ Warning: Do not use the API key from your test panel when setting up or deploying your production app. Each panel has its own unique API key. Even if you log in with a different account, this encrypted key stays the same. Using the wrong key can result in data being sent to the incorrect environment, causing potential issues or errors in your application.
Netmera Android SDK is served via maven repository. All you need to do is adding following configurations to your build.gradle
file. AndroidManifest
and other resource configurations are done automatically via Android gradle build tool.
In your project's build gradle file, add the following dependency.
In your app's build gradle file, add the following dependency.
Add the following into the top of app's build.gradle file.
Important Note for Obfuscation:
If you are obfuscating your code, you don't need to add any specific rules for Netmera. Netmera's functionality remains intact even with code obfuscation.
To initialize Netmera, add the following lines of code within the onCreate()
method of your class that extends android.app.Application
.
If you don't have such a class, create it and add it to your AndroidManifest file using the android:name
attribute within the application tag.
Please make sure you get the API key value from the relevant panel:
YOUR_SDK_API_KEY: You can get the api key from Developers > API > SDK API Key from your Netmera panel.
If you have a custom Firebase Messaging integration, you can use the following code snippets to handle Netmera push notifications:
Applications targeting API Level 33 and above have the privilege to request push notification permissions from users at their discretion, a decision enforced by the Android operating system. However, for applications below this API level, running on devices with Android 13 or higher, the operating system automatically prompts the user for these permissions during the first creation of a notification channel.
As Netmera SDK generates notification channels after the initialization response, and we recommend customers to call the init
method at the application level, this permission request is automatically triggered as soon as the application is launched. Nevertheless, this behavior is specific to applications targeting Android API Level 32 and below, and it applies only on devices running Android 13.
On devices with Android 12 and earlier, the system already assumes that this permission has been granted by default.
For applications targeting API Level 33, Netmera SDK provides two significant methods for handling push notification permissions:
public static boolean areNotificationsEnabled()
: This method allows you to check whether the application has acquired the necessary permissions. If the system has successfully obtained the required permissions from the user, this method returns true
; otherwise, it returns false
.
public static void requestNotificationPermissions(Activity activity)
: This method can be used to initiate a request for permissions to the system at any time, triggering the necessary steps to obtain the permissions.
By using these methods, applications can effectively manage push notification permissions in compliance with Android's latest requirements.
React Native SDK integration has been successfully completed, and your devices are now ready to receive the following types of push notifications sent via the Netmera Dashboard:
Standard Push Notifications
Interactive Push Notifications (If you've configured and published them using the Dashboard)
Push Notifications with Web View Content
Push Notifications with Deeplinks (If your application supports URL Scheme-based deeplinks and you've configured the application's URL Scheme in the Dashboard.)