Push Notifications

Learn how to configure Push Notifications in your Wisej Mobil

Local and push notifications are great for keeping users informed with timely and relevant content, whether your app is running in the background or inactive. Notifications can display a message, play a distinctive sound, or update a badge on your app icon.

You must have access to the Wisej Mobile Self-Hosted or Managed package to configure Push Notifications.

Requirements

  • Wisej Mobile Self-Hosted or Managed Package

Android

  • Server Authorization Key

You can generate a Server Authorization key from the Firebase Console.

Navigate to Project Settings > Cloud Messaging > Server Key

iOS

  • .p12 Certificate for the app bundle

  • Bundle Identifier (i.e. com.itg.wisej.mobile)

Usage

  • Wisej Application with Wisej-2-MobileIntegration NuGet package.

Get the Device's Notification Token

private void Page1_Load(object sender, EventArgs e)
{
    Device.SubscribedNotification += Device_SubscribedNotification;
}

private void Device_SubscribedNotifications(object sender, DeviceEventArgs e)
{
    // e.Data is the remote notification token.
    var token = e.Data;
    
    // updated token also available in:
    var token = Device.Info.DeviceToken;
}

Sending a Push Notification (Android)

private void PushNotification(string title, string message, int badge)
{
	var serverKey = File.ReadAllText(Application.MapPath("Data/ServerAuthKey.lic"));
	NotificationResponse result = NotificationManager.PushAndroid(serverKey, new
	{
		to = Device.Info.DeviceToken,
		notification = new
		{
			badge = badge,
			title = title,
			body = message,
		}
	});
	AlertBox.Show(result.ToString());
}

Sending a Push Notification (iOS)

private void PushNotification(string title, string message, int badge)
{
	var certPath = Application.MapPath("Data\\Certificates.p12");
	NotificationResponse result = NotificationManager.PushiOS("com.Wisej.Mobile.Demo", new string[] { Device.Info.DeviceToken }, certPath, "", new
	{
		aps = new
		{
			alert = new
			{
				title = title,
				body = message,
			},
			badge = badge
		}
	});
	AlertBox.Show(result.ToString());
}

Last updated