{"id":20340208,"url":"https://github.com/webengage/react-native-webengage","last_synced_at":"2025-10-29T21:39:14.778Z","repository":{"id":37768282,"uuid":"129770268","full_name":"WebEngage/react-native-webengage","owner":"WebEngage","description":"WebEngage React Native SDK","archived":false,"fork":false,"pushed_at":"2024-11-25T07:29:12.000Z","size":13625,"stargazers_count":8,"open_issues_count":4,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T23:17:31.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebEngage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-16T16:01:35.000Z","updated_at":"2024-11-25T07:29:13.000Z","dependencies_parsed_at":"2022-08-08T22:00:45.037Z","dependency_job_id":"5852f099-7d0f-4221-a53b-495af228a857","html_url":"https://github.com/WebEngage/react-native-webengage","commit_stats":{"total_commits":62,"total_committers":14,"mean_commits":4.428571428571429,"dds":0.8387096774193549,"last_synced_commit":"ce0fa7b55b968cee7e9a3950d7e52ef268cdbb5e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Freact-native-webengage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Freact-native-webengage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Freact-native-webengage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Freact-native-webengage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebEngage","download_url":"https://codeload.github.com/WebEngage/react-native-webengage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492885,"owners_count":21113163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T21:20:13.988Z","updated_at":"2025-10-29T21:39:14.709Z","avatar_url":"https://github.com/WebEngage.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Version](https://img.shields.io/npm/v/react-native-webengage.svg)](https://www.npmjs.com/package/react-native-webengage) [![Downloads](https://img.shields.io/npm/dm/react-native-webengage.svg)](https://www.npmjs.com/package/react-native-webengage) [![LastUpdated](https://img.shields.io/github/last-commit/WebEngage/react-native-webengage.svg)](https://docs.webengage.com/docs/react-native-getting-started)\n\nThis project contains WebEngage React Native SDK(lib) and a Sample Project(ExampleApp).\n\n# Sample Project\n\nTo run Sample Project please follow below steps:\n\n1. Navigate to ExampleApp folder\n\n2.  npm install --save\n\n3.  For Android, replace ```YOUR_LICENSE_CODE``` with your WebEngage license code and ```YOUR_PUSH_PROJECT_NUMBER``` with your push project number in [MainApplication.java](https://github.com/WebEngage/react-native-webengage/blob/master/ExampleApp/android/app/src/main/java/com/exampleapp/MainApplication.java) file.\n\n4. For iOS, replace ```YOUR_LICENSE_CODE``` with your WebEngage license code in [Info.plist](https://github.com/WebEngage/react-native-webengage/blob/master/ExampleApp/ios/ExampleApp/Info.plist) file.\n\n5. Now run you project using ```react-native run-android``` or ```react-native run-ios```.\n\n\n# WebEngage React Native SDK\n\nFor complete integration guide please refer to our [official documentation](https://docs.webengage.com/docs/react-native-getting-started).\n\n\n## Installation\n\n1. Install React Native WebEngage SDK.\n\n```shell\nnpm install react-native-webengage --save\n```\n\n2. Link the React Native WebEngage SDK.\n\n```shell\nreact-native link react-native-webengage\n```\n\n\n## Integration\n\n### Integration for Android\n\n1. Add Native WebEngage dependency in app-level build.gradle file at `android/app/build.gradle`.\n\n```gradle\ndependencies {\n    ...\n    implementation 'com.webengage:android-sdk:3.+'\n    implementation 'com.google.android.gms:play-services-ads:15.0.1'\n}\n```\n\n2. Initialise WebEngage SDK in `android/app/src/main/java/[your/package]/MainApplication.java` file.\n\n```java\n...\nimport com.webengage.sdk.android.WebEngageConfig;\nimport com.webengage.sdk.android.WebEngageActivityLifeCycleCallbacks;\nimport com.webengage.sdk.android.WebEngage;\n\npublic class MainApplication extends Application implements ReactApplication {\n    ...\n\n    @Override\n    public void onCreate() {\n        ...\n        WebEngageConfig webEngageConfig = new WebEngageConfig.Builder()\n                .setWebEngageKey(YOUR_LICENSE_CODE)\n                .setAutoGCMRegistrationFlag(false)\n                .setDebugMode(true)  // only in development mode\n                .build();\n        registerActivityLifecycleCallbacks(new WebEngageActivityLifeCycleCallbacks(this, webEngageConfig));\n    }\n}\n```\n\n**Note**: Replace YOUR_LICENSE_CODE with your WebEngage license code.\n\n3. Attribution Tracking (Optional)\n\nIf you need to track app installs and user acquisition attributes, then add the following receiver tag in your `android/app/src/main/AndroidManifest.xml` file.\n\n```xml\n\u003cmanifest\n    ...\u003e\n    \u003capplication ...\u003e\n        ...\n        \u003creceiver\n            android:name=\"com.webengage.sdk.android.InstallTracker\"\n            android:exported=\"true\"\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"com.android.vending.INSTALL_REFERRER\" /\u003e\n            \u003c/intent-filter\u003e\n        \u003c/receiver\u003e\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n\n### Integration for iOS\n\n1. Install WebEngage pod in `ios/` directory.\n\nInstall cocoapods (only if not already installed).\n\n```shell\nsudo gem install cocoapods\n```\n\nCreate Podfile by executing the following command in `ios` directory.\n\n```shell\npod init\n```\n\nAdd pod WebEngage under your target app in the newly created Podfile.\n\n```\ntarget 'YourAppTarget' do\n  ...\n  # For react-native-webengage v1.1.0 and above\n  pod 'react-native-webengage', :path =\u003e '../node_modules/react-native-webengage'\n\n  # For react-native-webengage v1.0.8 and below\n  # pod 'WebEngage'\n  ...\nend\n```\n\nInstall pod by running the following command.\n\n```shell\npod install\n```\n\n2. Configure Info.plist.\n\nOpen YourProject.xcworkspace in Xcode and then add your license code in the `Info.plist` file.\n\nWEGLicenseCode : YOUR_LICENSE_CODE\n\n**Note**: Replace YOUR_LICENSE_CODE with your WebEngage license code.\n\n3. Initialize WebEngage SDK in `AppDelegate.m` file.\n\n```objective-c\n...\n#import \u003cWebEngage/WebEngage.h\u003e\n\n@implementation AppDelegate\n\n...\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n  ...\n\n  [[WebEngage sharedInstance] application:application\n            didFinishLaunchingWithOptions:launchOptions];\n\n  return YES;\n}\n\n@end\n```\n\nIf you are getting the error: 'react/rctbundleurlprovider.h' file not found, then simply exit Xcode and then run the command 'npm install' in your project's root directory.\n\n\n## Initialisation\n\nIn your `App.js` file, initialise WebEngage bridge as shown.\n\n```javascript\n...\nimport WebEngage from 'react-native-webengage';\n...\n\nvar webengage = new WebEngage();\n\nexport default class App extends Component\u003cProps\u003e {\n    ...\n}\n...\n```\n\n\n## Push Notifications\n\n### Push Notifications for Android using FCM\n\n1. Register your app in Firebase Console.\n\nAdd your app in [Firebase console](https://console.firebase.google.com) and then download the generated google-services.json file. Copy and paste this google-services.json file in android/app/ directory.\n\n2. Add Google repository in project-level build gradle `android/build.gradle` file.\n\n```gradle\nbuildscript {\n    ...\n    repositories {\n        google()\n        jcenter()\n    }\n    dependencies {\n        ...\n        classpath 'com.google.gms:google-services:4.0.1'\n    }\n}\n\nallprojects {\n    repositories {\n        mavenLocal()\n        google()\n        jcenter()\n        ...\n    }\n}\n```\n\n**Note**: Make sure that you have google() repository is placed above jcenter().\n\n3. Add firebase messaging dependency in app-level build gradle `android/app/build.gradle` file.\n\n```gradle\n...\ndependencies {\n    ...\n    implementation 'com.google.firebase:firebase-messaging:17.3.4'\n}\n...\n\napply plugin: 'com.google.gms.google-services'\n```\n\n4. Add `MyFirebaseMessagingService.java` file in `android/app/src/main/java/[your-package-name]/`. This file must be parallel to `MainActivity.java` and `MainApplication.java` files.\n\n```java\npackage your.package;\n\nimport com.google.firebase.messaging.FirebaseMessagingService;\nimport com.google.firebase.messaging.RemoteMessage;\nimport com.webengage.sdk.android.WebEngage;\nimport java.util.Map;\n\npublic class MyFirebaseMessagingService extends FirebaseMessagingService {\n    @Override\n    public void onMessageReceived(RemoteMessage remoteMessage) {\n        Map\u003cString, String\u003e data = remoteMessage.getData();\n        if (data != null) {\n            if (data.containsKey(\"source\") \u0026\u0026 \"webengage\".equals(data.get(\"source\"))) {\n                WebEngage.get().receive(data);\n            }\n        }\n    }\n\n    @Override\n    public void onNewToken(String s) {\n        super.onNewToken(s);\n        WebEngage.get().setRegistrationID(s);\n    }\n}\n```\n\n**Note**: Replace your.package with your package name in the first line of MyFirebaseMessagingService.java file. This line should be same as in your MainActivity and MainApplication files.\n\n5. Add this Firebase Messaging service in the `AndroidManifest.xml` file.\n\n```xml\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"your.package\"\u003e\n    ...\n    \u003capplication\n        ...\u003e\n\n        ...\n\n        \u003cservice android:name=\".MyFirebaseMessagingService\"\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"com.google.firebase.MESSAGING_EVENT\" /\u003e\n            \u003c/intent-filter\u003e\n        \u003c/service\u003e\n\n    \u003c/application\u003e\n\n\u003c/manifest\u003e\n```\n\n**Note**: Replace 'your.package' for package attribute in manifest tag with your package name.\n\n6. Send the FCM token to WebEngage in `MainActivity.java` file as shown below.\n\n```java\n...\nimport android.os.Bundle;\nimport com.google.android.gms.tasks.OnSuccessListener;\nimport com.google.firebase.iid.FirebaseInstanceId;\nimport com.google.firebase.iid.InstanceIdResult;\nimport com.webengage.sdk.android.WebEngage;\n\npublic class MainActivity extends ReactActivity {\n    ...\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        try {\n            FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(this, new OnSuccessListener\u003cInstanceIdResult\u003e() {\n                @Override\n                public void onSuccess(InstanceIdResult instanceIdResult) {\n                    String token = instanceIdResult.getToken();\n                    WebEngage.get().setRegistrationID(token);\n                }\n            });\n        } catch (Exception e) {\n            // Handle exception\n        }\n    }\n}\n```\n\n7. Set Auto GCM Registration Flag to false in WebEngageConfig in `MainApplication.java` file as shown below.\n\n```java\n...\npublic class MainApplication extends Application implements ReactApplication {\n  ...\n  @Override\n  public void onCreate() {\n    ...\n    WebEngageConfig webEngageConfig = new WebEngageConfig.Builder()\n              ...\n              .setAutoGCMRegistrationFlag(false)\n              ...\n              .build();\n    registerActivityLifecycleCallbacks(new WebEngageActivityLifeCycleCallbacks(this, webEngageConfig));\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Freact-native-webengage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebengage%2Freact-native-webengage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Freact-native-webengage/lists"}