Create notification group
You can group the notifications displayed on the notification center. The notifications from the same event can be grouped and collapsed. The collapsed notification group can be expanded again by a user, and each member of a notification group can be accessed individually.
The notification group can be created in the Hive console > Notification > Register Push Campaign > Campaign Register > Option > Group Key. Change the Group Key to Use and add a group key value. After creating a group in the Hive console, you can apply notification group with the groupId
when you send a local push or remote push. If the notification group is applied, the notifications will be displayed, collapsed by group, as shown below.
|
|
iOS 10 Advanced Notification
As Apple added UserNotifications.framework on iOS 10, you can attach images or video clips with this framework in the notification.
System Requirements
- It requires Xcode 8.0 and MacOS version available, and a device capable of iOS 10 installation.
- In the OS of lower version, even the Extension is applied, same notification is received.
iOS 10.1 and lower may have troubles at times to run the Extension with media due to defective OS. If so, set the Deployment Target of Extension as 10.2 and implement for the OS with 10.1 and lower version to receive general notification type.
Running Process
This function runs by utilizing Notification Service Extension (“Extension”) of iOS.
Notification Service Extension is one of App Extension that allows you to modify Payload before Remote Notification is delivered to users. It is a technology available to use the process of other apps (UI or function) without changing the context.
For more information, see More.
File Capacity and Type Restriction
Capacity is limited to attach media files. For more information about this, see UNNotificationAttachment.
Type | Format | Capacity |
---|---|---|
Image | JPG, JPEG, PNG, GIF | 10MB |
Video | MP4, AVI | 50MB |
- If timeout occurs due to network problems, user will receive general notifications without media.
- On slow-speed networks, downloads may take up to 10 minutes, so make sure to use media with reasonable capacity in consideration of the local network conditions.
Implementation
Some settings and source code additions are required to download the media, reconfigure the Notification objects, and deliver them to users.
Notification Service Extension cannot be included in library or framework. Therefore, you must set up based on the guide provided by Hive to use Extension.
Adding Extension
To use this feature, you need to add the Notification Service Extension to your project, and add a new target to the project, without manually adding or overriding the class.
When you add a target to a project, a template is automatically generated.
1. In the project settings, click the plus-shaped button (the red square below) to add a target.
2. Select the Notification Service Extension, and click Next.
(Notification Service Extension is available to add on the project as a target with Xcode 8 and later)
4. When the page pop ups as follows, click Activate button.
Extension will be automatically embedded with the current project, and Scheme for build will be added.
5. Confirm the added Extension on General tab.
6. A new template class named NotificationService is added to the project.
7. Set the Deployment Target of added Extension as 10.2 and later.
Adding HIVEExtensions Framework
HIVEExtension.framework, provided by Hive, makes it easy to download media.
To add HIVEExtensionFramework:
1. Add the Framework manually.
- Add HIVEExtension.framework in the project.
-
When the page pops up as follows, check the target of added Extension and click Finish button.
2. Configure Framework Search Paths.
Add the save route of HIVEExtension.framework to Xcodeproj > Select the generated Extension Target > Build Settings > Framework Search Paths.
3. Configure Framework Status.
With the game which supports iOS 10.2 and lower, set HIVEExtensions.framework as Optional.
Applying Framework
Import the Framework to NotificationService.m as the following sample code.
Implement to call the method provided by HIVEExtensions.framework from the method in the template, and then delete the initial template code in the method.
1 2 3 4 5 6 7 8 9 10 |
#import <HIVEExtensions/HIVEExtensions.h> - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { [HIVENotificationService didReceiveNotificationRequest:request withContentHandler:contentHandler]; } - (void)serviceExtensionTimeWillExpire { [HIVENotificationService serviceExtensionTimeWillExpire]; } |
Notes on Media Application
Difference in sending and receiving time
After the Extension finishes all tasks, sending notification to users may cause a disparity in sending time and receiving time. Client will display the time server sent.
For example, if you send a notification at 15:00 and the download is completed at 15:05, then the notification arrival time is at 15:00.
Device Capacity
The media delivered via push service is stored in the user device and exposed by push notification. The received media is stored in the internal cache memory, and occupies the internal capacity of the user device.
The OS deletes some data from the cache data space when the internal storage capacity of user device is insufficient.
Using user’s mobile data
Media download uses the mobile data of users. The media is delivered via push notification, and the downloading will proceed without user’s agreement, so data usage cost may be incurred for downloading.
When user receives an audio or video file via push service, check the network connection status of each user before downloading. If a user did not enable Wi-Fi, expose the push without media to prevent downloading.
The type of media delivered through the push notification is checked with the extension specified at the end of the media URL, and only the extension specified in the [File Capacity and Type Restriction] item is exposed.
Transferred URL | Wi-Fi | LTE/3G |
http://xxx/notimovie.mp4 | Always expose the media on the push notification after download | Expose the media on the push notification without download as the extension for video file is specified (.mp4) |
http://xxx/notimovie | Always expose the media on the push notification after download | Expose the media on the push notification after download as it is not an audio or media file |
http://xxx/notisound.wav | Always expose the media on the push notification after download | Expose the media on the push notification without download as the extension for audio file is specified (.wav) |
http://xxx/notiimage.jpg | Always expose the media on the push notification after download | Expose the media on the push notification after download as it is not an audio or media file |
App Transport Security settings
Generally Apple policy is to allow https with server communication processed in all apps. This policy influences with the URL receiving through notifications. If you want to use http, setting App Transport Security (“ATS“) exceptions is necessary.
Configure ATS exceptions in the Extension to utilize http in the receiving URL via push notification even the application already processed ATS exceptions.
How to troubleshoot Bitcode errors
If the bitcode is activated in the settings of added Extension, errors as follows may occur. When the error occurs, set Xcodeproj > Select the generated Extension Target > Build Settings > Enable Bitcode as No.
In case of media transmission error on Unity
1 2 |
Hub connection error Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.com2us.hivesdk.normal.freefull.apple.global.ios.universal.NotificationServiceExtension" UserInfo={NSDebugDescription=connection to service named com.com2us.hivesdk.normal.freefull.apple.global.ios.universal.NotificationServiceExtension} |
Sometimes media transmission occurs errors on Unity exposing the error logs above. In this circumstance, check whether the Architectures of generated Extension Target contain the values of both armv7 and arm64.