v0.5.5版本,适配iOS本地通知

master
raoxudong 5 years ago
parent 394f6c957c
commit e38d470622

@ -332,7 +332,7 @@
"languageVersion": "2.0"
}
],
"generated": "2020-01-08T02:13:44.176682Z",
"generated": "2020-05-13T02:22:14.501535Z",
"generator": "pub",
"generatorVersion": "2.7.0"
"generatorVersion": "2.7.2"
}

@ -1,4 +1,4 @@
# Generated by pub on 2020-01-08 10:13:44.149541.
# Generated by pub on 2020-05-13 10:22:14.477463.
analyzer:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.37.0/lib/
args:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/args-1.5.2/lib/
async:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.3.0/lib/

@ -1,3 +1,6 @@
## 0.5.5
+ 适配iOS点击本地通知的通知栏消息响应事件
+ 更新最新Android SDK
## 0.5.3
+ 修复一个可能引起崩溃的日志打印代码
## 0.5.2

@ -16,7 +16,7 @@ dependencies:
// pub 集成
dependencies:
jpush_flutter: 0.5.3
jpush_flutter: 0.5.5
```
### 配置

@ -34,8 +34,8 @@ android {
}
dependencies {
implementation 'cn.jiguang.sdk:jpush:3.5.4'
implementation 'cn.jiguang.sdk:jcore:2.2.6'
implementation 'cn.jiguang.sdk:jpush:3.6.0'
implementation 'cn.jiguang.sdk:jcore:2.3.4'
// implementation 'com.android.support:appcompat-v7:28.+'
compileOnly files('libs/flutter.jar')

@ -1,13 +1,20 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.36.4"
version: "0.39.8"
archive:
dependency: transitive
description:
@ -63,7 +70,7 @@ packages:
name: coverage
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.13.3+3"
version: "0.13.9"
crypto:
dependency: transitive
description:
@ -84,7 +91,7 @@ packages:
name: cupertino_icons
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
version: "0.1.3"
flutter:
dependency: "direct main"
description: flutter
@ -95,48 +102,41 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
front_end:
dependency: transitive
description:
name: front_end
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.19"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.7"
version: "1.2.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.14.0+2"
version: "0.14.0+3"
http:
dependency: transitive
description:
name: http
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.0+2"
version: "0.12.1"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
version: "2.2.0"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.3"
version: "3.1.4"
image:
dependency: transitive
description:
@ -150,14 +150,14 @@ packages:
name: io
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.3"
version: "0.3.4"
jpush_flutter:
dependency: "direct dev"
description:
path: ".."
relative: true
source: path
version: "0.5.2"
version: "0.5.5"
js:
dependency: transitive
description:
@ -165,20 +165,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.1+1"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.19"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.11.3+2"
version: "0.11.4"
matcher:
dependency: transitive
description:
@ -214,20 +207,34 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.2"
node_interop:
dependency: transitive
description:
name: node_interop
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
node_io:
dependency: transitive
description:
name: node_io
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.5"
version: "1.4.8"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
version: "1.9.3"
package_resolver:
dependency: transitive
description:
@ -262,7 +269,7 @@ packages:
name: platform
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.0"
version: "2.2.1"
pool:
dependency: transitive
description:
@ -276,7 +283,7 @@ packages:
name: pub_semver
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.2"
version: "1.4.4"
quiver:
dependency: transitive
description:
@ -330,7 +337,7 @@ packages:
name: source_maps
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.10.8"
version: "0.10.9"
source_span:
dependency: transitive
description:
@ -407,21 +414,21 @@ packages:
name: vm_service
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.0"
version: "2.3.1"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.7+12"
version: "0.9.7+15"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.14"
version: "1.1.0"
xml:
dependency: transitive
description:
@ -435,6 +442,6 @@ packages:
name: yaml
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.16"
version: "2.2.1"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.7.0 <3.0.0"

@ -496,8 +496,43 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
_launchNotification = localNotificationEvent;
}
//[self performSelector:@selector(addNotificationWithDateTrigger) withObject:nil afterDelay:2];
return YES;
}
- (void)addNotificationWithDateTrigger {
JPushNotificationTrigger *trigger = [[JPushNotificationTrigger alloc] init];
if (@available(iOS 10.0, *)) {
trigger.timeInterval = 10;
} else {
NSDate *fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
trigger.fireDate = fireDate;
}
JPushNotificationContent *content = [[JPushNotificationContent alloc] init];
content.title = @"title";
content.subtitle = @"subtitle";
content.body = @"body";
content.badge = @(1);
content.action = @"action";
content.categoryIdentifier = @"categoryIdentifier";
content.threadIdentifier = @"threadIdentifier";
JPushNotificationRequest *request = [[JPushNotificationRequest alloc] init];
request.content = content;
request.trigger = trigger;
request.completionHandler = ^(id result) {
// iOS10以上成功则resultUNNotificationRequest对象,失败则resultnil
// iOS10以下成功resultUILocalNotification对象,失败则resultnil
if (result) {
NSLog(@"添加日期通知成功 --- %@", result);
}
};
request.requestIdentifier = @"123";
[JPUSHService addNotification:request];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// _resumingFromBackground = YES;
@ -508,22 +543,11 @@ static NSMutableArray<FlutterResult>* getRidResults;
// application.applicationIconBadgeNumber = 0;
}
- (bool)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
[_channel invokeMethod:@"onReceiveNotification" arguments:userInfo];
completionHandler(UIBackgroundFetchResultNoData);
return YES;
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[JPUSHService registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
NSDictionary *settingsDictionary = @{
@"sound" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeSound],
@"badge" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeBadge],
@ -532,29 +556,84 @@ didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSe
[_channel invokeMethod:@"onIosSettingsRegistered" arguments:settingsDictionary];
}
- (BOOL)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
JPLog(@"application:didReceiveRemoteNotification:fetchCompletionHandler");
[JPUSHService handleRemoteNotification:userInfo];
[_channel invokeMethod:@"onReceiveNotification" arguments:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
return YES;
}
// iOS 10 以下点击本地通知
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
JPLog(@"application:didReceiveLocalNotification:");
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
NSString *title = @"";
if (@available(iOS 8.2, *)) {
title = notification.alertTitle;
} else {
// Fallback on earlier versions
}
NSString *body = notification.alertBody;
NSString *action = notification.alertAction;
[dic setValue:title?:@"" forKey:@"title"];
[dic setValue:body?:@"" forKey:@"body"];
[dic setValue:action?:@"" forKey:@"action"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.channel invokeMethod:@"onOpenNotification" arguments:dic];
});
}
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler API_AVAILABLE(ios(10.0)){
JPLog(@"jpushNotificationCenter:willPresentNotification::");
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
[_channel invokeMethod:@"onReceiveNotification" arguments: [self jpushFormatAPNSDic:userInfo]];
}else{
JPLog(@"iOS10 前台收到本地通知:userInfo%@",userInfo);
}
completionHandler(notificationTypes);
}
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler API_AVAILABLE(ios(10.0)){
JPLog(@"jpushNotificationCenter:didReceiveNotificationResponse::");
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
[_channel invokeMethod:@"onOpenNotification" arguments: [self jpushFormatAPNSDic:userInfo]];
}else{
// iOS 10 以上点击本地通知
JPLog(@"iOS10 点击本地通知");
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
NSString *identifier = response.notification.request.identifier;
NSString *body = response.notification.request.content.body;
NSString *categoryIdentifier = response.notification.request.content.categoryIdentifier;
NSString *title = response.notification.request.content.title;
NSString *subtitle = response.notification.request.content.subtitle;
NSString *threadIdentifier = response.notification.request.content.threadIdentifier;
[dic setValue:body?:@"" forKey:@"body"];
[dic setValue:title?:@"" forKey:@"title"];
[dic setValue:subtitle?:@"" forKey:@"subtitle"];
[dic setValue:identifier?:@"" forKey:@"identifier"];
[dic setValue:threadIdentifier?:@"" forKey:@"threadIdentifier"];
[dic setValue:categoryIdentifier?:@"" forKey:@"categoryIdentifier"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.channel invokeMethod:@"onOpenNotification" arguments:dic];
});
}
completionHandler();
}
- (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
JPLog(@"");
BOOL isEnabled = NO;
if (status == JPAuthorizationStatusAuthorized) {
isEnabled = YES;

@ -1,6 +1,6 @@
name: jpush_flutter
description: JIGUANG officially supported JPush Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件Android & iOS(https://www.jiguang.cn).
version: 0.5.3
version: 0.5.5
author: xudong.rao <xudong.rao@outlook.com>
homepage: https://www.jiguang.cn

Loading…
Cancel
Save