-
Notifications
You must be signed in to change notification settings - Fork 20
Rich Push Notifications
megamegax edited this page Feb 20, 2020
·
8 revisions
Push notification could show media content and action buttons besides the title and body. Push notifications with these types of contents are called Rich Notifications.
- Mobile Engage backend is setup for sending push notifications already
- application is setup for receiving push notifications already
- use Emarsys SDK notification extension as mentioned in documentation
Note
Only HTTPS image URLs are supported.
Mode | Text | Image |
---|---|---|
Notification center collapsed | Title is 1 line and it’s truncated if too long. Body is 4 line and it’s truncated if too long. | The small image preview is shown on the right side. Title is 1 line and it’s truncated if too long. Body is 4 line and it’s truncated if too long. |
Lockscreen collapsed | Title is 1 line and it’s truncated if too long. Body is 4 line and it’s truncated if too long. | The small image preview is shown on the right side. Title is 1 line and it’s truncated if too long. Body is 4 line and it’s truncated if too long. |
Floating collapsed | Title is 1 line and it’s truncated if too long. Body is 2 line and it’s truncated if too long. | The small image preview is shown on the right side. Title is 1 line and it’s truncated if too long. Body is 2 line and it’s truncated if too long. |
Expanded | Title is 1 line and it’s truncated if too long. If the body is very long than it will be scrollable. | The image is shown at the top. Title is 1 line and it’s truncated if too long. If the body is very long than it will be scrollable. |
`Podfile`
target "Emarsys Sample" do
pod 'EmarsysSDK'
end
target "EMSNotificationService" do
pod 'EmarsysNotificationService'
end
`<NameOfYourExtension-Bridging-Header.h>`
```swift
#import <EmarsysNotificationService/EMSNotificationService.h>
```
* import the EmarsysNotificationService
* extend the class `EMSNotificationService` instead of `UNNotificationServiceExtension`
```swift
import EmarsysNotificationService
class NotificationService: EMSNotificationService {
}
```
6. Request authorization for push notifications in the AppDelegate
application:didFinishLaunchingWithOptions:
method, like in our sample application
application.registerForRemoteNotifications()
var options: UNAuthorizationOptions = [.alert, .sound, .badge]
UNUserNotificationCenter.current().requestAuthorization(options: options) { [unowned self] granted, error in
print(granted, error ?? "no error")
if (granted) {
Emarsys.notificationCenterDelegate.eventHandler = self
UNUserNotificationCenter.current().delegate = Emarsys.notificationCenterDelegate
}
}
In order to react to an event, triggered by a push notification message, you have the following options:
- If you integrate the Emarsys SDK with the EMSAppDelegate, you just have to override the handleEvent method.
- Otherwise, you need to implement the EMSEventHandler protocol in your AppDelegate.