public override void OnMessageReceived(RemoteMessage message) { base.OnMessageReceived(message); IDictionary <string, string> data = message.Data; if (data.ContainsKey("source") && "webengage".Equals(data["source"])) { WebEngage.Get().Receive(data); } }
protected override void OnStart() { base.OnStart(); // Tracking Screens IDictionary <string, Object> attributes = new Dictionary <string, Object>(); attributes.Add("name", "Home"); attributes.Add("launcher", true); WebEngage.Get().Analytics().ScreenNavigated("Home", attributes); }
protected override void OnStart() { base.OnStart(); Log.Debug("WebEngageTest", "Next Activity started"); // Tracking next screen Dictionary <string, Java.Lang.Object> attributes = new Dictionary <string, Java.Lang.Object>(); attributes.Add("name", "Next"); attributes.Add("launcher", false); WebEngage.Get().Analytics().ScreenNavigated("Next", attributes); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { inAppNotificationDelegate = new InAppNotificationDelegate(); bool autoRegister = true; WebEngage.SharedInstance().Application(application, launchOptions, inAppNotificationDelegate, autoRegister); //WebEngage.SharedInstance().Application(application, launchOptions); //WebEngage.SharedInstance().Application(application, launchOptions, true); //WebEngage.SharedInstance().Application(application, launchOptions, inAppNotificationDelegate); return(true); }
public override void OnCreate() { base.OnCreate(); // Initialize WebEngage WebEngageConfig config = new WebEngageConfig.Builder() .SetWebEngageKey("YOUR-WEBENGAGE-LICENSE-CODE") .SetDebugMode(true) .SetEventReportingStrategy(ReportingStrategy.Buffer) .SetLocationTrackingStrategy(LocationTrackingStrategy.AccuracyCity) .Build(); RegisterActivityLifecycleCallbacks(new WebEngageActivityLifeCycleCallbacks(this, config)); // Send the latest push token to WebEngage string token = FirebaseInstanceId.Instance.Token; WebEngage.Get().SetRegistrationID(token); // Register callbacks WebEngage.RegisterPushNotificationCallback(new MyPushNotificationCallbacks()); WebEngage.RegisterInAppNotificationCallback(new MyInAppNotificationCallbacks()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); ISharedPreferences prefs = Application.Context.GetSharedPreferences("TEST_PREF", FileCreationMode.Private); // Tracking Users EditText userIdEditText = FindViewById <EditText>(Resource.Id.userIdEditText); userId = prefs.GetString("userid", ""); userIdEditText.Text = userId; Button loginButton = FindViewById <Button>(Resource.Id.loginButton); if (userId.Equals("")) { loginButton.Text = "LOGIN"; } else { loginButton.Text = "LOGOUT"; } loginButton.Click += delegate { if (loginButton.Text.Equals("LOGIN")) { userId = userIdEditText.Text.ToString(); if (!userId.Equals("")) { ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("userid", userId); editor.Apply(); loginButton.Text = "LOGOUT"; // Login WebEngage.Get().User().Login(userId); } } else { ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("userid", ""); editor.Apply(); loginButton.Text = "LOGIN"; userIdEditText.Text = ""; // Logout WebEngage.Get().User().Logout(); } }; // System user attributes EditText emailEditText = FindViewById <EditText>(Resource.Id.emailEditText); Button emailButton = FindViewById <Button>(Resource.Id.emailButton); emailButton.Click += delegate { string email = emailEditText.Text.ToString(); if (!email.Equals("")) { WebEngage.Get().User().SetEmail(email); Toast.MakeText(this.ApplicationContext, "Email set successfully", ToastLength.Long).Show(); } }; Spinner genderSpinner = FindViewById <Spinner>(Resource.Id.genderSpinner); var adapter = ArrayAdapter.CreateFromResource( this, Resource.Array.gender_array, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); genderSpinner.Adapter = adapter; Button genderButton = FindViewById <Button>(Resource.Id.genderButton); genderButton.Click += delegate { int spinnerPosition = genderSpinner.SelectedItemPosition; Gender gender = Gender.Male; if (spinnerPosition == 0) { gender = Gender.Male; } else if (spinnerPosition == 1) { gender = Gender.Female; } else if (spinnerPosition == 2) { gender = Gender.Other; } WebEngage.Get().User().SetGender(gender); Toast.MakeText(this.BaseContext, "Gender set successfully", ToastLength.Long).Show(); }; //WebEngage.Get().User().SetBirthDate("1994-04-29"); //WebEngage.Get().User().SetFirstName("John"); //WebEngage.Get().User().SetLastName("Doe"); //WebEngage.Get().User().SetCompany("WebEngage"); //WebEngage.Get().User().SetPhoneNumber("+551155256325"); //WebEngage.Get().User().SetHashedPhoneNumber("e0ec043b3f9e198ec09041687e4d4e8d"); //WebEngage.Get().User().SetHashedEmail("144e0424883546e07dcd727057fd3b62"); // Channels //WebEngage.Get().User().SetOptIn(Channel.Whatsapp, true); //WebEngage.Get().User().SetOptIn(Channel.Email, true); //WebEngage.Get().User().SetOptIn(Channel.Sms, true); //WebEngage.Get().User().SetOptIn(Channel.Push, true); //WebEngage.Get().User().SetOptIn(Channel.InApp, true); // Custom user attributes //WebEngage.Get().User().SetAttribute("age", (Java.Lang.Integer)23); //WebEngage.Get().User().SetAttribute("premium", (Boolean)true); //WebEngage.Get().User().SetAttribute("last_seen", new Date("2018-12-25")); //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>(); //customAttributes.Add("Twitter Email", "*****@*****.**"); //customAttributes.Add("Subscribed", true); //WebEngage.Get().User().SetAttributes(customAttributes); //WebEngage.Get().User().DeleteAttribute("age"); //WebEngage.Get().SetLocationTrackingStrategy(LocationTrackingStrategy.AccuracyCity); //WebEngage.Get().User().SetLocation(12.23, 12.45); //IList<Object> brandAffinity = new List<Object> //{ // "Hugo Boss", // "Armani Exchange", // "GAS", // "Brooks Brothers" //}; //WebEngage.Get().User().SetAttribute("Brand affinity", brandAffinity); //JavaDictionary<string, Object> address = new JavaDictionary<string, Object> //{ // { "Flat", "Z-62" }, // { "Building", "Pennant Court" }, // { "Locality", "Penn Road" }, // { "City", "Wolverhampton" }, // { "State", "West Midlands" }, // { "PIN", "WV30DT" } //}; //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>(); //customAttributes.Add("Address", address); //WebEngage.Get().User().SetAttributes(customAttributes); // Tracking Events EditText eventEditText = FindViewById <EditText>(Resource.Id.eventEditText); Button trackButton = FindViewById <Button>(Resource.Id.trackButton); trackButton.Click += delegate { string eventName = eventEditText.Text; if (!eventName.Equals("")) { WebEngage.Get().Analytics().Track(eventName, new Analytics.Options().SetHighReportingPriority(false)); Toast.MakeText(this.BaseContext, "Event tracked successfully", ToastLength.Long).Show(); } }; // Tracking Event with Attributes //IDictionary<string, Object> attributes = new Dictionary<string, Object> //{ // { "id", "~123" }, // { "price", 100 }, // { "discount", true } //}; //WebEngage.Get().Analytics().Track("Product Viewed", attributes, new Analytics.Options().SetHighReportingPriority(false)); Button shopButton = FindViewById <Button>(Resource.Id.shopButton); shopButton.Click += delegate { // Tracking Complex Events IDictionary <string, Object> product1 = new JavaDictionary <string, Object>(); product1.Add("SKU Code", "UHUH799"); product1.Add("Product Name", "Armani Jeans"); product1.Add("Price", 300.49); JavaDictionary <string, Object> detailsProduct1 = new JavaDictionary <string, Object>(); detailsProduct1.Add("Size", "L"); product1.Add("Details", detailsProduct1); IDictionary <string, Object> product2 = new JavaDictionary <string, Object>(); product2.Add("SKU Code", "FBHG746"); product2.Add("Product Name", "Hugo Boss Jacket"); product2.Add("Price", 507.99); JavaDictionary <string, Object> detailsProduct2 = new JavaDictionary <string, Object>(); detailsProduct2.Add("Size", "L"); product2.Add("Details", detailsProduct2); IDictionary <string, Object> deliveryAddress = new JavaDictionary <string, Object>(); deliveryAddress.Add("City", "San Francisco"); deliveryAddress.Add("ZIP", "94121"); JavaDictionary <string, Object> orderPlacedAttributes = new JavaDictionary <string, Object>(); JavaList <Object> products = new JavaList <Object>(); products.Add(product1); products.Add(product2); JavaList <string> coupons = new JavaList <string>(); coupons.Add("BOGO17"); orderPlacedAttributes.Add("Products", products); orderPlacedAttributes.Add("Delivery Address", deliveryAddress); orderPlacedAttributes.Add("Coupons Applied", coupons); WebEngage.Get().Analytics().Track("Order Placed", orderPlacedAttributes, new Analytics.Options().SetHighReportingPriority(false)); Toast.MakeText(this.BaseContext, "Order Placed successfully", ToastLength.Long).Show(); }; Button locationButton = FindViewById <Button>(Resource.Id.locationButton); locationButton.Click += delegate { requestLocationPermission(); }; Button nextButton = FindViewById <Button>(Resource.Id.nextButton); nextButton.Click += delegate { StartActivity(typeof(NextActivity)); }; }
private void sample() { /* * Tracking Users */ WebEngage.SharedInstance().User.Login("120543"); WebEngage.SharedInstance().User.Logout(); // System user attributes WebEngage.SharedInstance().User.SetFirstName("John"); WebEngage.SharedInstance().User.SetLastName("Doe"); WebEngage.SharedInstance().User.SetEmail("*****@*****.**"); WebEngage.SharedInstance().User.SetHashedEmail("144e0424883546e07dcd727057fd3b62"); WebEngage.SharedInstance().User.SetPhone("*****@*****.**"); WebEngage.SharedInstance().User.SetHashedPhone("e0ec043b3f9e198ec09041687e4d4e8d"); WebEngage.SharedInstance().User.SetGender("male"); WebEngage.SharedInstance().User.SetBirthDateString("1994-04-29"); WebEngage.SharedInstance().User.SetCompany("Alphabet Inc."); WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Push, true); WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.InApp, true); WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Sms, true); WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Email, true); NSNumber latitude = 72.5; NSNumber longitude = 19.3; WebEngage.SharedInstance().User.SetUserLocation(latitude, longitude); // Custom user attributes WebEngage.SharedInstance().User.SetAttribute("Twitter username", "johndoe86@orig"); NSDateComponents dateComponents = new NSDateComponents { Day = 29, Month = 4, Year = 2001 }; NSCalendar calendar = NSCalendar.CurrentCalendar; NSDate date = calendar.DateFromComponents(dateComponents); WebEngage.SharedInstance().User.SetAttribute("Last order date", date); // List of user attributes NSObject[] nsArray = { new NSString("xcode"), new NSString("xcode") }; WebEngage.SharedInstance().User.SetAttribute("IDEs", nsArray); // Complex custom user attributes NSDictionary <NSString, NSObject> dict = new NSDictionary <NSString, NSObject>(); dict.SetValueForKey(new NSString("Z-62"), new NSString("Flat")); dict.SetValueForKey(new NSString("Pennant Court"), new NSString("Building")); dict.SetValueForKey(new NSString("Penn Road"), new NSString("Locality")); dict.SetValueForKey(new NSString("West Midlands"), new NSString("State")); dict.SetValueForKey(new NSString("WV30DT"), new NSString("PIN")); WebEngage.SharedInstance().User.SetAttribute("Address", dict); // Delete single custom user attribute WebEngage.SharedInstance().User.DeleteAttribute("age"); // Delete multiple custom user attributes NSObject[] attributesToDelete = new NSObject[] { new NSString("age"), new NSString("email") }; WebEngage.SharedInstance().User.DeleteAttributes(attributesToDelete); /* * Tracking Events */ WebEngage.SharedInstance().Analytics.TrackEventWithName("Product Viewed"); // Tracking event with attributes var addedToCartAttributes = new NSDictionary("Product ID", 1337, "Price", 39.80, "Quantity", 1, "Product", "Givenchy Pour Homme Cologne", "Category", "Fragrance", "Currency", "USD", "Is Premium", true ); WebEngage.SharedInstance().Analytics.TrackEventWithName("Added to Cart", addedToCartAttributes); // Tracking complex events var detailsProduct1 = new NSDictionary("Size", "L"); var product1 = new NSDictionary("SKU Code", "UHUH799", "Product Name", "Armani Jeans", "Price", 300.49, "Details", detailsProduct1 ); var detailsProduct2 = new NSDictionary("Size", "L"); var product2 = new NSDictionary("SKU Code", "UHUH799", "Product Name", "Armani Jeans", "Price", 300.49, "Details", detailsProduct1 ); var deliveryAddress = new NSDictionary("City", "San Francisco", "ZIP", "94121" ); var products = new NSMutableArray <NSDictionary>(product1, product2); var orderPlacedAttributes = new NSDictionary("Products", products, "Delivery Address", deliveryAddress, "Coupons Applied", new NSMutableArray <NSString>(new NSString("BOGO17"), new NSString("BGH025")) ); WebEngage.SharedInstance().Analytics.TrackEventWithName("Order Placed", orderPlacedAttributes); /* * Tracking screen */ WebEngage.SharedInstance().Analytics.NavigatingToScreenWithName("Purchase Screen"); // Screen data var screenData = new NSDictionary("productId", "~hs7674", "price", 1200); // Tracking screen with data WebEngage.SharedInstance().Analytics.NavigatingToScreenWithName("Purchase Screen", screenData); // Updating screen data WebEngage.SharedInstance().Analytics.UpdateCurrentScreenData(screenData); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. NSUserDefaults plist = NSUserDefaults.StandardUserDefaults; string userid = plist.StringForKey("userid"); Console.WriteLine("user id: " + userid); if (userid != null && !userid.Equals("")) { UserIdTextField.Text = userid; LoginButton.SetTitle("Logout", UIControlState.Normal); } LoginButton.TouchUpInside += (object sender, EventArgs e) => { if (userid == null || userid.Equals("")) { // Login string newUserId = UserIdTextField.Text; if (newUserId != null && !newUserId.Equals("")) { plist.SetString(newUserId, "userid"); plist.Synchronize(); userid = newUserId; LoginButton.SetTitle("Logout", UIControlState.Normal); WebEngage.SharedInstance().User.Login(newUserId); } } else { // Logout plist.SetString("", "userid"); plist.Synchronize(); userid = ""; UserIdTextField.Text = ""; LoginButton.SetTitle("Login", UIControlState.Normal); WebEngage.SharedInstance().User.Logout(); } }; TrackButton.TouchUpInside += (object sender, EventArgs e) => { // Track string eventName = EventTextField.Text; if (eventName != null && !eventName.Equals("")) { WebEngage.SharedInstance().Analytics.TrackEventWithName(eventName); } }; SetButton.TouchUpInside += (object sender, EventArgs e) => { // Set screen string screen = ScreenTextField.Text; if (screen != null && !screen.Equals("")) { WebEngage.SharedInstance().Analytics.NavigatingToScreenWithName(screen); } }; TestButton.TouchUpInside += (object sender, EventArgs e) => { // For testing }; }
public override void OnReceive(Context context, Intent intent) { WebEngage.Get().Analytics().Installed(intent); }
void SendRegistrationToServer(string token) { WebEngage.Get().SetRegistrationID(token); }