{"id":20340215,"url":"https://github.com/webengage/webengage-unity","last_synced_at":"2025-04-11T23:17:28.555Z","repository":{"id":45294459,"uuid":"186012115","full_name":"WebEngage/webengage-unity","owner":"WebEngage","description":"WebEngage Unity Package for Android and iOS apps","archived":false,"fork":false,"pushed_at":"2023-03-29T11:31:43.000Z","size":36092,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T23:17:15.756Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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":"2019-05-10T15:29:44.000Z","updated_at":"2022-06-09T10:07:03.000Z","dependencies_parsed_at":"2024-11-14T21:21:51.728Z","dependency_job_id":"e6de3202-54a4-466c-81f2-ccd689e2eb9f","html_url":"https://github.com/WebEngage/webengage-unity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebEngage","download_url":"https://codeload.github.com/WebEngage/webengage-unity/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:15.726Z","updated_at":"2025-04-11T23:17:28.533Z","avatar_url":"https://github.com/WebEngage.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# WebEngage Unity\n\nWebEngage Unity plugin is for Android and iOS apps built with Unity. This unity-package will not work on any other platform.\n\n\n## Installation\n\n 1. Download the [WebEngageUnity.unitypackage](https://github.com/WebEngage/webengage-unity/raw/master/WebEngageUnity.unitypackage).\n\n 2. Import the downloaded unitypackage into your Unity project through `Assets` \u003e `Import Package` \u003e `Custom Package...`.\n\n 3. Replace the AAR file at `Assets/Plugins/Android/webengage-android-unity-X.X.X.aar` with the latest [webengage-android-unity.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/Assets/Plugins/Android/webengage-android-unity-3.16.0.aar).\n\n 4. Replace the framework file at `Assets/Plugins/iOS/WebEngage.framework` with the latest [WebEngage framework](https://github.com/WebEngage/webengage-unity-ios/raw/master/WebEngage.framework.zip). Unzip the downloaded zip file to get the framework.\n\n\n## Update Android\n\n 1. Replace the AAR file at `Assets/Plugins/Android/webengage-android-unity-X.X.X.aar` with the latest [webengage-android-unity.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/Assets/Plugins/Android/webengage-android-unity-3.16.0.aar).\n\n## Update iOS\n\n\n1. Download latest [XCFramework](https://webengage-sdk.s3.us-west-2.amazonaws.com/unity/ios/latest/WebEngage.xcframework.zip) for WebEngage\n\n2. Unzip zip file to get XCFramework file\n\n3. Copy Unzipped `XCFramework` inside your project folder\n\n4. Open Unity iOS Project in XCode\n\n5. In Xcode, go to your `Targets`, under `UnityFramework` Target, select `Build Phases`\n\n6. Add XCFramework under `Link Binary With Libraries`, You can drag and drop `XCFramework` or add thourgh + option under it\n\n![image](https://webengage-sdk.s3.us-west-2.amazonaws.com/unity/ios/images/IntegrationNativeStep.png)\n\n\n\n\n\n## Initialization\n\n 1. For Android, add the following meta-data tags in `Assets/Plugins/Android/AndroidManifest.xml` file of your Unity project.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    ...\u003e\n\n    \u003capplication\n    \t...\n        android:allowBackup=\"false\"\u003e\n\n\t    \u003cmeta-data android:name=\"com.webengage.sdk.android.key\" android:value=\"YOUR-WEBENGAGE-LICENSE-CODE\" /\u003e\n\n\t    \u003c!-- true if development build else false --\u003e\n\t    \u003cmeta-data android:name=\"com.webengage.sdk.android.debug\" android:value=\"true\" /\u003e\n\n\t    ...\n\t\u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nIf `AndroidManifest.xml` file does not exist in `Assets/Plugins/Android/` directory of your Unity project, then you can create a new `AndroidManifest.xml` file and copy the below content in it.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\u003e\n\n    \u003capplication\n        android:label=\"@string/app_name\"\n        android:icon=\"@drawable/app_icon\"\n        android:allowBackup=\"false\"\u003e\n\n        \u003cmeta-data android:name=\"com.webengage.sdk.android.key\" android:value=\"YOUR-WEBENGAGE-LICENSE-CODE\" /\u003e\n\n        \u003cmeta-data android:name=\"com.webengage.sdk.android.debug\" android:value=\"true\" /\u003e\n\n        \u003cactivity\n            android:name=\"com.unity3d.player.UnityPlayerActivity\"\n            android:configChanges=\"fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen\"\u003e\n\n            \u003cintent-filter\u003e\n\n                \u003caction\n                    android:name=\"android.intent.action.MAIN\" /\u003e\n\n                \u003ccategory\n                    android:name=\"android.intent.category.LAUNCHER\" /\u003e\n\n                \u003ccategory\n                    android:name=\"android.intent.category.LEANBACK_LAUNCHER\" /\u003e\n            \u003c/intent-filter\u003e\n\n            \u003cmeta-data\n                android:name=\"unityplayer.UnityActivity\"\n                android:value=\"true\" /\u003e\n        \u003c/activity\u003e\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n**Note:** Replace YOUR-WEBENGAGE-LICENSE-CODE with your own WebEngage license code.\n\n\n 2. Initialize the WebEngage SDK at start of your application.\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    private void Awake()\n    {\n        WebEngage.Engage();\n        ...\n    }\n    ...\n}\n```\n\n\n 3. For iOS, add the following values in `/Assets/Editor/WebEngagePostProcessBuild.cs` file.\n\n ```csharp\n...\n\npublic class WebEngagePostProcessBuild\n{\n    [PostProcessBuild]\n    public static void EditXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)\n    {\n        if (buildTarget == BuildTarget.iOS)\n        {\n        \t// Add your WebEngage license code\n        \tstring WEBENGAGE_LICENSE_CODE = \"YOUR-WEBENGAGE-LICENSE-CODE\";\n\n        \t// Set debug log level\n            string logLevel = \"VERBOSE\";\n        \t...\n        }\n    }\n}\n ```\n\n**Note:** Replace YOUR-WEBENGAGE-LICENSE-CODE with your own WebEngage license code.\n\n 4. Initialize the WebEngage SDK in your `AppDelegate.m` class.\n\n```objective-c\n#import \u003cWebEngage/WebEngage.h\u003e\n...\n\n-(BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) options\n{\n    [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:options];\n    \n    ...\n}\n\n```\n\nIf you are not already implementing `AppDelegate.m` in your Unity app, then create a new file at `/Assets/Plugins/iOS/OverrideAppDelegate.m` and copy the below contents in it.\n\n```objective-c\n#import \"UnityAppController.h\"\n#import \u003cWebEngage/WebEngage.h\u003e\n\n\n@interface OverrideAppDelegate : UnityAppController\n@end\n\n\nIMPL_APP_CONTROLLER_SUBCLASS(OverrideAppDelegate)\n\n@implementation OverrideAppDelegate\n\n-(BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) options\n{\n    [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:options];\n    \n    return [super application:application didFinishLaunchingWithOptions:options];\n}\n\n@end\n\n```\n\n\n## Attribution Tracking\n\nIn order to track 'App Installed' events and install-referrer URLs in Android, follow the steps below.\n\n1. Make sure that you are using webengage-android-unity.aar version 3.16.0 or above.\n\n2. Download the latest version of [Android Install Referrer library (aar)](https://mvnrepository.com/artifact/com.android.installreferrer/installreferrer).\n\n3. Add the aar file to your Unity project at the location `/Assets/Plugins/Android/installreferrer-X.X.X.aar`.\n\n\n## Tracking Users\n\n 1. Login and Logout\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    ...\n\n    // User login\n    WebEngage.Login(\"userId\");\n\n    // User logout\n    WebEngage.Logout();\n}\n```\n\n 2. Set system user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    // Set user first name\n    WebEngage.SetFirstName(\"John\");\n\n    // Set user last name\n    WebEngage.SetLastName(\"Doe\");  \n\n    // Set user email\n    WebEngage.SetEmail(\"john.doe@email.com\");\n\n    // Set user hashed email\n    WebEngage.SetHashedEmail(\"144e0424883546e07dcd727057fd3b62\");\n\n    // Set user phone number\n    WebEngage.SetPhoneNumber(\"+551155256325\");\n\n    // Set user hashed phone number\n    WebEngage.SetHashedPhoneNumber(\"e0ec043b3f9e198ec09041687e4d4e8d\");\n\n    // Set user gender, allowed values are ['male', 'female', 'other']\n    WebEngage.SetGender(\"male\");\n\n    // Set user birth-date, supported format: 'yyyy-mm-dd'\n    WebEngage.SetBirthDate(\"1994-04-29\");\n\n    // Set user company\n    WebEngage.SetCompany(\"Google\");\n\n    // Set opt-in status, channels: ['push', 'in_app', 'email', 'sms']\n    WebEngage.SetOptIn(\"push\", true);\n\n    // Set user location\n    double latitude = 19.0822;\n    double longitude = 72.8417;\n    WebEngage.SetLocation(latitude, longitude);\n}\n```\n\n3. Set custom user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    // Set custom user attributes\n    WebEngage.SetUserAttribute(\"age\", 25);\n    WebEngage.SetUserAttribute(\"premium\", true);\n\n    // Set multiple custom user attributes\n    Dictionary\u003cstring, object\u003e customAttributes = new Dictionary\u003cstring, object\u003e();\n    customAttributes.Add(\"Twitter Email\", \"john.twitter@mail.com\");\n    customAttributes.Add(\"Subscribed\", true);\n    WebEngage.SetUserAttributes(customAttributes);\n```\n**Note:** WebEngage SDK only supports the following data-types: string, bool, int, long, float, double, DateTime, List and Dictionary.\n\n4. Delete custom user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    \n    WebEngage.DeleteUserAttribute(\"age\");\n```\n\n\n## Tracking Events\n\nTrack custom events as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n\n    // Track simple event\n    WebEngage.TrackEvent(\"Product - Page Viewed\");\n\n    // Track event with attributes\n    Dictionary\u003cstring, object\u003e orderPlacedAttributes = new Dictionary\u003cstring, object\u003e();\n    orderPlacedAttributes.Add(\"Amount\", 808.48);\n    orderPlacedAttributes.Add(\"Product 1 SKU Code\", \"UHUH799\");\n    orderPlacedAttributes.Add(\"Product 1 Name\", \"Armani Jeans\");\n    orderPlacedAttributes.Add(\"Product 1 Price\", 300.49);\n    orderPlacedAttributes.Add(\"Product 1 Size\", \"L\");\n    orderPlacedAttributes.Add(\"Product 2 SKU Code\", \"FBHG746\");\n    orderPlacedAttributes.Add(\"Product 2 Name\", \"Hugo Boss Jacket\");\n    orderPlacedAttributes.Add(\"Product 2 Price\", 507.99);\n    orderPlacedAttributes.Add(\"Product 2 Size\", \"L\");\n    orderPlacedAttributes.Add(\"Delivery Date\", System.DateTime.ParseExact(\"2017-10-21 09:27:37.100\", \"yyyy-MM-dd HH:mm:ss.fff\", null));\n    orderPlacedAttributes.Add(\"Delivery City\", \"San Francisco\");\n    orderPlacedAttributes.Add(\"Delivery ZIP\", \"94121\");\n    orderPlacedAttributes.Add(\"Coupon Applied\", \"BOGO17\");\n    WebEngage.TrackEvent(\"Order Placed\", orderPlacedAttributes);\n\n    // Track complex event\n    Dictionary\u003cstring, object\u003e product1 = new Dictionary\u003cstring, object\u003e();\n    product1.Add(\"SKU Code\", \"UHUH799\");\n    product1.Add(\"Product Name\", \"Armani Jeans\");\n    product1.Add(\"Price\", 300.49);\n\n    Dictionary\u003cstring, object\u003e detailsProduct1 = new Dictionary\u003cstring, object\u003e();\n    detailsProduct1.Add(\"Size\", \"L\");\n    product1.Add(\"Details\", detailsProduct1);\n\n    Dictionary\u003cstring, object\u003e product2 = new Dictionary\u003cstring, object\u003e();\n    product2.Add(\"SKU Code\", \"FBHG746\");\n    product2.Add(\"Product Name\", \"Hugo Boss Jacket\");\n    product2.Add(\"Price\", 507.99);\n\n    Dictionary\u003cstring, object\u003e detailsProduct2 = new Dictionary\u003cstring, object\u003e();\n    detailsProduct2.Add(\"Size\", \"L\");\n    product2.Add(\"Details\", detailsProduct2);\n\n    Dictionary\u003cstring, object\u003e deliveryAddress = new Dictionary\u003cstring, object\u003e();\n    deliveryAddress.Add(\"City\", \"San Francisco\");\n    deliveryAddress.Add(\"ZIP\", \"94121\");\n\n    Dictionary\u003cstring, object\u003e orderPlacedAttributes = new Dictionary\u003cstring, object\u003e();\n    List\u003cobject\u003e products = new List\u003cobject\u003e();\n    products.Add(product1);\n    products.Add(product2);\n\n    List\u003cstring\u003e coupons = new List\u003cstring\u003e();\n    coupons.Add(\"BOGO17\");\n\n    orderPlacedAttributes.Add(\"Products\", products);\n    orderPlacedAttributes.Add(\"Delivery Address\", deliveryAddress);\n    orderPlacedAttributes.Add(\"Coupons Applied\", coupons);\n\n    WebEngage.TrackEvent(\"Order Placed\", orderPlacedAttributes);\n```\n\n**Note:** WebEngage SDK only supports the following data-types: string, bool, int, long, float, double, DateTime, List and Dictionary.\n\n\n## Push Notifications for Android\n\n#### 1. Using FCM Unity Plugin\n\n1. Import FCM Unity plugin as instructed [here](https://firebase.google.com/docs/cloud-messaging/unity/client) into your Unity project.\n\n2. If you have replaced the `Assets/Plugins/Android/AndroidManifest.xml` then make sure to add back your WebEngage license-code and debug-mode meta-data tags in the `AndroidManifest.xml` file.\n\n3. In your script where you have registered callbacks for `OnTokenReceived` and `OnMessageReceived`, add the following code snippets.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =\u003e {\n        var dependencyStatus = task.Result;\n        if (dependencyStatus == Firebase.DependencyStatus.Available)\n        {\n            Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;\n            Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;\n        }\n        else\n        {\n            ...\n        }\n    });\n    \n    public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token)\n    {\n        ...\n        WebEngage.SetPushToken(token.Token);\n    }\n\n    public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)\n    {\n        Dictionary\u003cstring, string\u003e data = new Dictionary\u003cstring, string\u003e(e.Message.Data);\n        if (data.ContainsKey(\"source\") \u0026\u0026 \"webengage\".Equals(data[\"source\"]))\n        {\n            WebEngage.SendPushData(data);\n        }\n        ...\n    }\n```\n\nPush notifications will work as expected when app is in foreground.\n\n**Note**: Drawback of this approach is that push notifications will not be shown when app is in background. However those push notifications are cached and will be shown on next app launch. If you wish to prevent this drawback, then follow the Overriding FCM Unity Plugin approach given below.\n\n#### 2. Overriding FCM Unity Plugin\n\n1. Import FCM Unity plugin as instructed [here](https://firebase.google.com/docs/cloud-messaging/unity/client) into your Unity project.\n\n2. If you have replaced the `Assets/Plugins/Android/AndroidManifest.xml` then make sure to add back your WebEngage license-code and debug-mode meta-data tags in the `AndroidManifest.xml` file.\n\n3. Download and add the [webengage-android-fcm.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/webengage-android-fcm-0.0.1.aar) file in `Assets/Plugins/Android/` directory of your Unity project.\n\n4. Add the following service tag in your `Assets/Plugins/Android/AndroidManifest.xml` file as shown below.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    ...\u003e\n\n    \u003capplication\n        ...\u003e\n\n        \u003cservice android:name=\"com.webengage.android.fcm.WebEngageFirebaseMessagingService\"\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        ...\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n5. Update the FCM registration token on app start as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n\n    WebEngage.UpdateFcmToken();\n```\n\n\n## Push Notifications for iOS\n\n 1. Build your iOS app through Unity Editor and open Unity-iPhone.xcodeproj in your Xcode IDE.\n\n 2. Select your main app target (Unity-iPhone), under Capabilities enable Push Notifications.\n\n 3. Also under Capabilities enable Background Modes and check Remote notifications.\n\n\n### Rich Push Notifications\n\n 1. Enable Push Notifications, App Groups and add the app group `group.\u003cyour-bundle-identifier\u003e.WEGNotificationGroup` to your App ID from your Apple Developer Account. Download and install the updated provisioning profile of your app in your Xcode.\n\n#### 1. Banner Push Notifications\n\n 1. Add a new App Bundle ID `\u003cyour-bundle-identifier\u003e.NotificationService`, enable Push Notifications, App Groups and add the group `group.\u003cyour-bundle-identifier\u003e.WEGNotificationGroup` in this newly created App ID from your Apple Developer Account. Download and install the provisioning profile of this App ID in your Xcode.\n\n 2. Download the [WebEngageNotificationService.unitypackage](https://github.com/WebEngage/webengage-unity-ios/raw/master/WebEngageNotificationService.unitypackage).\n\n 3. Import the downloaded unitypackage into your Unity project through `Assets` \u003e `Import Package` \u003e `Custom Package...`.\n\n 4. Build your iOS app through Unity Editor and open Unity-iPhone.xcodeproj in your Xcode IDE.\n\n 5. Verify that NotificationService extension is added and linked to your main app target.\n\n#### 2. Rating and Carousel Push Notifications\n\n 1. Add the App Bundle ID `\u003cyour-bundle-identifier\u003e.NotificationViewController`, enable Push Notifications, App Groups and add the group `group.\u003cyour-bundle-identifier\u003e.WEGNotificationGroup` in this newly created App ID from your Apple Developer Account. Download and install the provisioning profile of this App ID in your Xcode.\n\n 2. Download the [WebEngageNotificationContent.unitypackage](https://github.com/WebEngage/webengage-unity-ios/raw/master/WebEngageNotificationContent.unitypackage).\n\n 3. Import the downloaded unitypackage into your Unity project through `Assets` \u003e `Import Package` \u003e `Custom Package...`.\n\n 4. Build your iOS app through Unity Editor and open Unity-iPhone.xcodeproj in your Xcode IDE.\n\n 5. Verify that NotificationViewController extension is added and linked to your main app target.\n\n\n#### Troubleshooting for Rich Push Notifications\n\n **1. If you are facing integration or build issues with rich-push notification unity plugins, then try adding the extensions and pods manually.**\n\n 1. Remove the WebEngageNotificationService.unitypackage and WebEngageNotificationContent.unitypackage plugins (if added).\n\n 2. Build your iOS app through Unity Editor and open Unity-iPhone.xcodeproj in your Xcode IDE.\n\n 3. Follow the instructions at [WebEngage documentation](https://docs.webengage.com/docs/ios-push-messaging#section-5-rich-push-notifications).\n\n\n## In-app Notifications\n\nNo additional steps are required for in-app notifications.\n\n### Tracking Screens\n\n```csharp\nusing WebEngageBridge;\n    ...\n    \n    // Set screen name\n    WebEngage.ScreenNavigated(\"Purchase Screen\");\n\n    // Update current screen data\n    Dictionary\u003cstring, object\u003e currentData = new Dictionary\u003cstring, object\u003e();\n    currentData.Add(\"productId\", \"~hs7674\");\n    currentData.Add(\"price\", 1200);\n    WebEngage.SetScreenData(currentData);\n\n    // Set screen name with data\n    Dictionary\u003cstring, object\u003e data = new Dictionary\u003cstring, object\u003e();\n    data.Add(\"productId\", \"~hs7674\");\n    data.Add(\"price\", 1200);\n    WebEngage.ScreenNavigated(\"Purchase Screen\", data);\n```\n\n# Callbacks\n\n### Push Notification Callbacks\n\nSet up callbacks in your Unity project by following these steps:\n\n#### 1. Push Notification Received (Only For Android Platform) : \n - `SetPushReceivedCallBack` allows you to obtain a callback when you get\n   a push notification.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\n    public static void pushReceivedCallback(string json)\n    {\n        Debug.Log(\"/*/*/*/* Unity Callback received on PUSH NOTIFICATION RECEIVED”);\n    }\n```\n\n - Add `SetPushReceivedCallBack` in your C#(.cs) code and send the previously constructed function as an argument\n    Eg.\n```csharp\n    WebEngage.setPushReceivedCallBack(pushReceivedCallback); \n```\n\n*As a result, whenever you receive a push notification, the code defined in the callback handler will run.*\n\n\n\n#### 2. Push Notification Clicked :\n - `setPushClickCallBack` allows you to obtain a callback when you click a push notification.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\npublic static void handlepushNotificationClicked(string json)\n{\n\tDebug.Log(\"/*/*/*/* Unity Callback received on PUSH NOTIFICATION CLICKED\");\n}\n```\n\n - Add `setPushClickCallBack` in your C#(.cs) code and send the previously constructed function as an argument\n    Eg.\n```csharp\n    WebEngage.setPushClickCallBack(handlepushNotificationClicked); \n```\n\n*As a result, whenever you click a push notification, the code defined in the callback handler will run.*\n\n\n### InApp Notification Callbacks\n\nSet up callbacks in your Unity project by following these steps:\n\n#### 1. InApp Notification Prepared :\n - `setInAppPreparedCallBack` allows you to obtain a callback when InApp Notification is prepared.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\n    public static void handleInAppNotificationPrepared(string json)\n    {\n        Debug.Log(\"/*/*/*/* Unity Callback received on InApp Notification prepared”);\n    }\n```\n\n - Add `setInAppPreparedCallBack` in your C#(.cs) code and send the previously constructed function as an argument\n    Eg.\n```csharp\n    WebEngage.setInAppPreparedCallBack(handleInAppNotificationPrepared); \n```\n\n*As a result, whenever you receive a push notification, the code defined in the callback handler will run.*\n\n\n\n#### 2. InApp Notification Shown :\n - `setInAppShownCallBack` allows you to obtain a callback when InApp Notification is shown on the screen.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\npublic static void handleInAppNotificationShown(string json)\n{\n\tDebug.Log(\"/*/*/*/* Unity Callback received on InApp Notification Shown“);\n}\n```\n\n - Add `setInAppShownCallBack` in your C#(.cs) code and send the previously constructed function as an argument    \n \nEg.\n```csharp\n    WebEngage.setInAppShownCallBack(handleInAppNotificationShown); \n```\n\n*As a result, whenever InApp Notification is shown on to the screen, the code defined in the callback handler will run.*\n\n#### 3. InApp Notification Clicked :\n - `setInAppClickedCallBack` allows you to obtain a callback when InApp Notification is Clicked.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\npublic static void handleInAppNotificationClicked(string json)\n{\n\tDebug.Log(\"/*/*/*/* Unity Callback received on InApp Notification Clicked“);\n}\n```\n\n - Add `setInAppClickedCallBack` in your C#(.cs) code and send the previously constructed function as an argument    \n \nEg.\n```csharp\n    WebEngage.setInAppClickedCallBack(handleInAppNotificationClicked); \n```\n\n*As a result, whenever InApp Notification is Clicked, the code defined in the callback handler will run.*\n\n#### 4.  InApp Notification Dismissed :\n - `setInAppDismissedCallBack` allows you to obtain a callback when InApp Notification is Dismissed.\n   \n - Create  `[MonoPInvokeCallback(typeof(callback))]` type method with any name in which you wish to receive callback\n\n Eg.  \n```csharp\n[MonoPInvokeCallback(typeof(callback))]\npublic static void handleInAppNotificationDismissed(string json)\n{\n\tDebug.Log(\"/*/*/*/* Unity Callback received on InApp Notification Dismissed“);\n}\n```\n\n - Add `setInAppDismissedCallBack` in your C#(.cs) code and send the previously constructed function as an argument    \n \nEg.\n```csharp\n    WebEngage.setInAppDismissedCallBack(handleInAppNotificationDismissed); \n```\n\n*As a result, whenever InApp Notification is Dismissed, the code defined in the callback handler will run.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fwebengage-unity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebengage%2Fwebengage-unity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fwebengage-unity/lists"}