Managing Notifications

Detailed in this page is how you can set up push notifications as well as manage in-app notifications for new in-app chat messages.

Push Notifications

You can enable Instabug to send your users push notifications each time you send them a new message.

1040

An example of a push notification from Instabug.

Uploading Your Push Certificate

Follow the steps below to upload your push certificate to your Instabug dashboard.

  1. Follow this tutorial to generate a push certificate and export it to a .pem file.
  2. Go to the Push Notifications page on your Instabug dashboard and upload your .pem file.
  3. Select whether the certificate you're uploading is for development or production, and enter the pass phrase if you set one.

Handling Instabug Notifications

In application:didRegisterForRemoteNotificationsWithDeviceToken:, pass the token you get to Instabug.

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Replies.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [IBGReplies didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

When you receive a notification, check if it's an Instabug notification, then pass it to Instabug if necessary.

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    let isInstabugNotification = Replies.didReceiveRemoteNotification(userInfo)
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    BOOL isInstabugNotification = [IBGReplies didReceiveRemoteNotification:userInfo];
}

And finally, handle when your application has been launched from an Instabug notification. Add the following to application:didFinishLaunchingWithOptions:.

if let notification = launchOptions?[.remoteNotification] as? [String: AnyObject] {
   let isInstabugNotification = Replies.didReceiveRemoteNotification(notification)
 }
NSDictionary *notificationDictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

BOOL isInstabugNotification = [IBGReplies didReceiveRemoteNotification:notificationDictionary];

Disabling Push Notifications

Push notifications are enabled by default if you upload a push certificate to your Instabug dashboard. To disable them, use the following method.

Replies.pushNotificationsEnabled = false
[IBGReplies setPushNotificationsEnabled:NO];

In-App Notifications

By default, a notification will be shown on top of your app's UI when a new message is received.

1038

An example of an in-app notification.

📘

Email Notifications

If your user doesn't view the new message within 10 minutes, they will be sent an email notification as well.

Disabling In-App Notifications

Use the following method to disable notifications that appear in-app.

Replies.inAppNotificationsEnabled = false
IBGReplies.inAppNotificationsEnabled = NO;

Getting Unread Messages Count

You can use the following method to get the number of messages a user has yet to read.

let messageCount = Replies.unreadRepliesCount
NSUInteger messageCount = IBGReplies.unreadRepliesCount;

What’s Next

Learn to identify your users so that push notifications always go to the correct user. Also check out how to communicate with your users by chatting with them through different pages in your dashboard.