Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Push messaging

Push notifications are messages that pop up on mobile devices. App publishers can send them at any time; even if the recipients aren’t currently engaging with the app or using their devices.

Before continuing, please be sure that you have completed all of the steps in Getting started.

WebEngage push messaging can be integrated using Apple Push Notification service. To integrate WebEngage in your iOS application, you need to be enrolled in Apple Developer Program.

If you already support push notifications in your app, skip to the section below about uploading your push certificate. Note that you may still need to enable background modes.

1. Enable push and background modes capabilities

  1. Enter Project Navigator view.
  2. Select your main app target from the expanded sidebar or from the dropdown menu, then select the Capabilities tab.
  3. If Push Notifications isn't enabled, click the switch to add the "Push Notifications" entitlement to your app. If you are using Xcode 8 or above, ensure that a YOUR-APP-NAME.entitlements file has been added to your project.
  4. If Background Modes is not enabled, click the switch and then tick the Remote notifications checkbox. WebEngage uses background modes to track when push messages are received on a user's device before the message is opened.

2. Create Apple Push Notification service Client SSL Certificate

  1. Log in to the Apple Developer console and go to Certificates, Identifiers & Profiles.
  2. Select Identifiers > App IDs and then select your app.
  1. Click Edit to update the app settings.
  2. If not already enabled, tick the Push Notifications service checkbox to enable it.
  3. If you already have a certificate created which you can use, download it and proceed to the next step. If not, click Create Certificate….
  4. Follow the instructions on the next webpage to create a certificate request on your Mac, and click Continue.
  5. On the Generate your certificate page, click Choose File and choose the certificate request file you just created (with a .certSigningRequest extension) and then click Continue.
  6. Download the generated certificate to your Mac and then open the .cer file to install it in Keychain Access.

Because Apple treats development and production as separate instances, we strongly suggest making two applications in the WebEngage dashboard. This will allow you test your application even after releasing it without interrupting your users.

3. Upload push certificate

To allow WebEngage to send push messages on your behalf, you must provide WebEngage with the certificate you generated.

  1. Launch Keychain Access on your Mac.
  2. In the Category section, select My Certificates.

Make sure you select My Certificates on the lower left-hand side. If My Certificates is not highlighted, you will not be able to export the certificate as a .p12 file.

  1. Find the certificate you generated and expand it to disclose its contents. You’ll see both a certificate and a private key.
  2. Select both the certificate and the key, and select File > Export Items... from the menu.
  1. Save the certificate in the Personal Information Exchange (.p12) format. You must enter a password to protect it.
  2. Log in to your WebEngage dashboard and navigate to Integrations > Channels.
  3. In Push tab, under the iOS section, select "Certificate" as APNs Authentication Type. Click Upload button against Push Certificate and upload the certificate.
  4. Enter the push certificate password under Push Password and select the Default Push Mode. Click Save.

4. Deep linking

WebEngage SDK supports URL based deep linking. On WebEngage dashboard, you can enter any valid URI while creating your push campaign. It can be an http / https link or a valid custom URI like yourapp://detailpage/1234

To handle custom deep links for more advanced use cases, the app can implement WEGHandleDeeplink in its AppDelegate. If this method is implemented, WebEngage SDK will not handle any deep links (including external links) and will call this method instead. The method will receive the deep link string provided on the dashboard along with the whole push notification payload including any custom data sent via dashboard. You can then implement your own logic of handling deep links.

-(void)WEGHandleDeeplink:(NSString*) deeplink userData:(NSDictionary*)data;
func WEGHandleDeeplink(_ deeplink: String, userData data: [AnyHashable: Any]) {
}

5. Rich push notifications (optional)

Requires iOS 10.0 or above. and WebEngage SDK Version 4.0.2+

Before continuing, please be sure that you have completed all of the steps in Getting started.

1. Create Notification Service Extension

  1. In Xcode, navigate to File > New > Target and select Notification Service Extension.
  2. Click Next, fill out the Product Name as NotificationService, and click Finish.
  3. Click Activate on the prompt shown to activate the service extension. Xcode will now create a new top level folder in your project with the name NotificationService.

2. Create Notification Content Extension

In Xcode, navigate to File > New > Target and select Notification Content Extension.
Click Next, fill out the Product Name as NotificationViewController, and click Finish.
Click Activate on the prompt shown to activate the content extension. Xcode will now create a new top level folder in your project with the name NotificationViewController.

3. Update service and content extension classes

If you are using Objective-C:

  1. Replace NotificationService.h with the below code.
#import <UserNotifications/UserNotifications.h>
#import <WebEngageBannerPush/WEXPushNotificationService.h>

@interface NotificationService : WEXPushNotificationService

@end
  1. Replace NotificationService.m with the below code.
#import "NotificationService.h"

@implementation NotificationService
    
@end
  1. Replace NotificationViewController.h with the below code.
#import <UIKit/UIKit.h>
#import <WebEngageAppEx/WEXRichPushNotificationViewController.h>

@interface NotificationViewController : WEXRichPushNotificationViewController

@end
  1. Replace NotificationViewController.m with the below code.
#import "NotificationViewController.h"
#import <UserNotifications/UserNotifications.h>
#import <UserNotificationsUI/UserNotificationsUI.h>

@implementation NotificationViewController

@end

If you are using Swift:

Bridging Header Required

If you are using Swift for any of the extensions you would need to add bridging header file to the Extension Target as described here. No specific entries are needed in the bridging header, but it just needs to be setup.

  1. Replace NotificationService.swift with the below code.
import UserNotifications
import WebEngageBannerPush

class NotificationService: WEXPushNotificationService {
}
  1. Replace NotificationViewController.swift with the below code.
import UIKit
import WebEngageAppEx

class NotificationViewController: WEXRichPushNotificationViewController {
}

4. Add WebEngage to all the targets

Add the following in your Podfile above the project’s target.

target 'NotificationService' do
    platform :ios, '10.0'
    pod 'WebEngageBannerPush'
end

target 'NotificationViewController' do
  platform :ios, '10.0'
  pod 'WebEngageAppEx/ContentExtension'
end

Make sure you replace NotificationService and NotificationViewController target names with the ones created in above steps, in case you used different names.

5. Reinitialize the Pods

Navigate to your Xcode project directory and run the following commands to reinitialize the pods.

$ pod deintegrate
$ pod install

6. Create App Groups for all targets

  1. Enter Project Navigator view.
  2. Select your main app target from the expanded sidebar or from the dropdown menu, then select the Capabilities tab.
  3. If App Groups isn't enabled, click the switch to add the "App Groups" entitlement to your app. If you are using Xcode 8 or above, ensure that an YOUR-APP-NAME.entitlements file has been added to your project.
  4. Add an App Group container and specify its name. We recommend using this format: group.<your-bundle-identifier>.WEGNotificationGroup. Make sure this App Group is in use by ticking the checkbox against it.
  5. Select the NotificationService target from the expanded sidebar or from the dropdown menu, then select the Capabilities tab. Click on the checkbox against the added App Group and tick it.
  6. Do the same for NotificationViewController target. Select the NotificationViewController target from the expanded sidebar or from the dropdown menu, then select the Capabilities tab. Click on the checkbox against the added App Group and tick it.

7. Configure Info.plist

  1. Open the Info.plist file for NotificationViewController. Expand NSExetnsion > NSExtensionAttributes. Look for UNNotificationExtensionCategory under NSExtensionAttributes. Add it if it is not present and set the type as Array. In its items, add:
    a. WEG_CAROUSEL_V1 for Carousel Push Notifications
    b. WEG_RATING_V1 for Push Notifications with Rating
  2. Set UNNotificationExtensionDefaultContentHidden under NSExtensionAttributes to YES universally for all rich push layouts (Carousel/Rating/Banner).
  3. If your image URLs provided for push on the dashboard use http (instead of https), add App Transport Security Settings key under Information Property List in both NotificationService and NotificationViewController Info.plist files. Set Allow Arbitrary Loads to YES under App Transport Security Settings in both these files.

If you are using WebEngage iOS SDK version below 3.5.8, add WEG_APP_GROUP key in the Info.plist files of all the three targets: main app, NotificationService and NotificationViewController. Set the App Group name created in Create App Groups step for all targets step as the value of this key.


What's Next

In-app messaging

Push messaging