SDK Integration
Step 1: Install React Native
Please see the following document on React Native Installation.
Install the Package
a. Automatic Installation
Run the following command to link the SDK:
No extra Netmera SDK libraries are required for Android or iOS.
b. Manual Installation
Add the following line to your Podfile
to integrate iOS SDK into your project.
Step 2: Setup iOS
1. Create an Apple Push Notification Certificate
Log in to developer.apple.com with your Apple Developer account.
Generate an Apple Push Notification Certificate for your app.
Export the certificate using Keychain Access on your Mac.
Upload the exported certificate to the Netmera panel by navigating to Developer > Push Backends > iOS in the left menu.
Bundle IDs should match on your project, certificate and panel:
Ensure that the certificate you upload to the panel matches the bundle ID of your project. Additionally, set your project's bundle ID in the panel to ensure consistency. The bundle ID of your project, the certificate, and the one specified in the panel must all align.
Certificate types:
For apps downloaded from the App Store or tested via TestFlight, the certificate type should be set to "prod".
For apps built directly from Xcode, the certificate type must be set to "dev".
If you have problems sending push notifications when you build from Xcode, verify the certificate type on the Developer > Push Backends > iOS page in Panel.
Creating an APNS .p8 Certificate (Recommended)
Creating an APNS .p12 Certificate
2. Integrate & Initialize Netmera iOS SDK
Install Pods
Navigate to the iOS folder in your terminal and run:
Initialize Netmera in
AppDelegate
Update your AppDelegate
class with the following codes:
To obtain your SDK API Key:
Go to the Netmera Panel.
Navigate to Developer > API > SDK API Key.
Copy your SDK API Key from this section.
Use this key to replace the [<YOUR NETMERA API KEY>]
placeholder in the sample code.
React Native Push Handling
When triggering [RNNetmeraRCTEventEmitter onPushReceive]
in AppDelegate
, the corresponding method is called in React Native:
3. Request Push Notification Authorization
Request push notification authorization:
Using iOS10 Media Push
For versions 3.14.4 and above, refer to the Media Push.
Podfile Configuration
Add the following outside of your target in your Podfile
:
Replace X.X.X
with the latest version from the SDK Versions page > Changelog
Step 3: Setup Android
1. Netmera Android Onboarding
In Netmera Panel:
Navigate to Developers > Netmera Onboarding.
Select Android and click Start to proceed.
2. Create a Firebase Configuration
Netmera uses Firebase Cloud Messaging (FCM) for delivering push notifications.
Go to the Firebase Developers Console and create a Firebase project.
Generate a new Private Key (JSON file) for your project.
Upload this file in Netmera Panel > Developers > Netmera Onboarding > Android > Step 2: Create A Firebase Configuration > FCM Service Account Key.
3. Select a Target SDK
Choose the React Native SDK based on your application framework.
4. Integrate and Initialize React Native SDK
Important Notes:
Do not use the API key from a test panel in production.
Each panel has a unique API key, and using the wrong one can result in data misdirection or errors.
To obtain your SDK API Key:
Go to the Netmera Panel.
Navigate to Developer > API > SDK API Key.
Copy your SDK API Key from this section.
5. Integrate Netmera Android SDK
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.
Gradle Configuration
Project’s
build.gradle
File
Add the following to your project-level build.gradle
file:
App’s
build.gradle
File
Add the required dependency and plugins to your app-level build.gradle
file:
At the top of your app’s
build.gradle
, include:
Important Note for Obfuscation:
If your code is obfuscated, there is no need to add any special rules for Netmera. Its functionality is unaffected by code obfuscation.
6. Initialize Netmera Android SDK
In your app, locate or create a class that extends
android.app.Application
.Inside this class, add the following code to the
onCreate()
method:
No class that extends android.app.Application
If you don’t have this class, create one.
Then, add it to your
AndroidManifest.xml
file under the<application>
tag using theandroid:name.
To obtain your SDK API Key:
Go to the Netmera Panel.
Navigate to Developer > API > SDK API Key.
Copy your SDK API Key from this section.
Use this key to (<YOUR NETMERA API KEY>)
placeholder in the sample code.
Custom Firebase Messaging Integration
If you are using Firebase Messaging in your app, you can use these code snippets to handle Netmera push notifications:
Get Firebase Token:
Handle Incoming Firebase Messages:
Custom Huawei Messaging Integration
For Huawei messaging, you can use the following code to manage push notifications:
Get Huawei Token:
Handle Incoming Huawei Messages:
7. Android 13 Push Notification Permissions
Android 13 introduced significant changes to how push notification permissions are handled.
Increased User Control: Apps targeting API Level 33 and above now have more control over when and how they request push notification permissions. This allows for a more user-friendly and context-aware permission request experience.
Automatic Permission Requests for Older Apps: For apps targeting API Level 32 and below running on Android 13, the system automatically prompts the user for push notification permission when the app creates its first notification channel.
Impact on Netmera SDK Users:
The Netmera SDK initializes and creates notification channels during the app's startup. Consequently:
On Android 13: For apps targeting API Level 32 and below, this initialization process will trigger the automatic system prompt for push notification permission.
On Android 12 and below: The system generally assumes push notification permission has already been granted.
If you initialize the Netmera SDK at app startup (which is recommended), the system will automatically request push notification permissions on Android 13 devices for apps targeting API Level 32 and below. For devices running Android 12 or earlier, the system assumes permission is already granted.
Netmera SDK Push Notification Permission Methods
For Android apps targeting API Level 33, the Netmera SDK provides two key methods to handle notification permissions:
Check Notification Permission Status:
This method checks if the app has the necessary permissions to send push notifications. It returns true
if the permission is granted, otherwise false
.
Request Notification Permissions:
Use this method to request notification permissions from the user. Call this method when you need to prompt the user for permissions at any time.
Push Enable/Disable User Flow:
Granting Permission:
The user triggers
requestNotificationPermissions()
, and if they grant permission, a push enable request is sent.
Handling Denial:
If the user denies permission, avoid resending the request immediately (as recommended by Google). Instead, the SDK opens the app's notification settings. The user can grant permission from the settings and return to the app, where a push enable request is sent.
Denying Permission:
If the user triggers
requestNotificationPermissions()
and denies permission, a push disable request is sent.
Reattempt After Denial:
If denied, avoid immediate re-request. The SDK will open the app's notification settings. If the user cancels (presses the back button), a push disable request is sent.
React Native SDK Integration Complete
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
Widgets
Push Notifications with Deeplinks
Last updated
Was this helpful?