Releases: jpush/jpush-unity3d-plugin
Releases · jpush/jpush-unity3d-plugin
Release 3.1.3
改动
- iOS 新增接收本地推送事件。
- 修复应用没启动点击通知无法正常回调问题。
配置更新改动
-
UnityAppController.mm 中的导入头文件
#import "JPushEventCache.h"
。 -
UnityAppController.mm 中的
didFinishLaunchingWithOptions
中如下代码:if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) { #ifdef NSFoundationVersionNumber_iOS_9_x_Max JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; entity.types = UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound; [JPUSHService registerForRemoteNotificationConfig:entity delegate:self]; #endif } #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { // 可以添加自定义 categories [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; } else { // categories 必须为 nil [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil]; } #else // categories 必须为 nil [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert) categories:nil]; #endif
替换成:
[[JPushEventCache sharedInstance] handFinishLaunchOption:launchOptions];
-
UnityAppController.mm 中的下列代码:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // Required. [[NSNotificationCenter defaultCenter] postNotificationName:@"JPushPluginReceiveNotification" object:userInfo]; [JPUSHService handleRemoteNotification:userInfo]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler { [[NSNotificationCenter defaultCenter] postNotificationName:@"JPushPluginReceiveNotification" object:userInfo]; }
替换成:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // Required. [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@"JPushPluginReceiveNotification"]; [JPUSHService handleRemoteNotification:userInfo]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler { [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@"JPushPluginReceiveNotification"]; } - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { NSDictionary* localNotificationEvent = @{@"content":notification.alertBody, @"badge": @(notification.applicationIconBadgeNumber), @"extras":notification.userInfo, }; [[JPushEventCache sharedInstance] sendEvent: localNotificationEvent withKey:@"JPushPluginReceiveNotification"]; }