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

master
raoxudong 5 years ago
parent 394f6c957c
commit e38d470622

@ -332,7 +332,7 @@
"languageVersion": "2.0" "languageVersion": "2.0"
} }
], ],
"generated": "2020-01-08T02:13:44.176682Z", "generated": "2020-05-13T02:22:14.501535Z",
"generator": "pub", "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/ 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/ 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/ 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.3
+ 修复一个可能引起崩溃的日志打印代码 + 修复一个可能引起崩溃的日志打印代码
## 0.5.2 ## 0.5.2

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

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

@ -1,13 +1,20 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.36.4" version: "0.39.8"
archive: archive:
dependency: transitive dependency: transitive
description: description:
@ -63,7 +70,7 @@ packages:
name: coverage name: coverage
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.13.3+3" version: "0.13.9"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -84,7 +91,7 @@ packages:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.2" version: "0.1.3"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -95,48 +102,41 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: glob:
dependency: transitive dependency: transitive
description: description:
name: glob name: glob
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.7" version: "1.2.0"
html: html:
dependency: transitive dependency: transitive
description: description:
name: html name: html
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.14.0+2" version: "0.14.0+3"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.0+2" version: "0.12.1"
http_multi_server: http_multi_server:
dependency: transitive dependency: transitive
description: description:
name: http_multi_server name: http_multi_server
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.2.0"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.1.3" version: "3.1.4"
image: image:
dependency: transitive dependency: transitive
description: description:
@ -150,14 +150,14 @@ packages:
name: io name: io
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.3.3" version: "0.3.4"
jpush_flutter: jpush_flutter:
dependency: "direct dev" dependency: "direct dev"
description: description:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.5.2" version: "0.5.5"
js: js:
dependency: transitive dependency: transitive
description: description:
@ -165,20 +165,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.1+1" version: "0.6.1+1"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.19"
logging: logging:
dependency: transitive dependency: transitive
description: description:
name: logging name: logging
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.11.3+2" version: "0.11.4"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -214,20 +207,34 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.2" 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: node_preamble:
dependency: transitive dependency: transitive
description: description:
name: node_preamble name: node_preamble
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.5" version: "1.4.8"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
name: package_config name: package_config
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.5" version: "1.9.3"
package_resolver: package_resolver:
dependency: transitive dependency: transitive
description: description:
@ -262,7 +269,7 @@ packages:
name: platform name: platform
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.0" version: "2.2.1"
pool: pool:
dependency: transitive dependency: transitive
description: description:
@ -276,7 +283,7 @@ packages:
name: pub_semver name: pub_semver
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.2" version: "1.4.4"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
@ -330,7 +337,7 @@ packages:
name: source_maps name: source_maps
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.10.8" version: "0.10.9"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -407,21 +414,21 @@ packages:
name: vm_service name: vm_service
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.2.0" version: "2.3.1"
watcher: watcher:
dependency: transitive dependency: transitive
description: description:
name: watcher name: watcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.9.7+12" version: "0.9.7+15"
web_socket_channel: web_socket_channel:
dependency: transitive dependency: transitive
description: description:
name: web_socket_channel name: web_socket_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.14" version: "1.1.0"
xml: xml:
dependency: transitive dependency: transitive
description: description:
@ -435,6 +442,6 @@ packages:
name: yaml name: yaml
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.16" version: "2.2.1"
sdks: 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; _launchNotification = localNotificationEvent;
} }
//[self performSelector:@selector(addNotificationWithDateTrigger) withObject:nil afterDelay:2];
return YES; 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 { - (void)applicationDidEnterBackground:(UIApplication *)application {
// _resumingFromBackground = YES; // _resumingFromBackground = YES;
@ -508,22 +543,11 @@ static NSMutableArray<FlutterResult>* getRidResults;
// application.applicationIconBadgeNumber = 0; // application.applicationIconBadgeNumber = 0;
} }
- (bool)application:(UIApplication *)application - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
[_channel invokeMethod:@"onReceiveNotification" arguments:userInfo];
completionHandler(UIBackgroundFetchResultNoData);
return YES;
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[JPUSHService registerDeviceToken:deviceToken]; [JPUSHService registerDeviceToken:deviceToken];
} }
- (void)application:(UIApplication *)application - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
NSDictionary *settingsDictionary = @{ NSDictionary *settingsDictionary = @{
@"sound" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeSound], @"sound" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeSound],
@"badge" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeBadge], @"badge" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeBadge],
@ -532,29 +556,84 @@ didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSe
[_channel invokeMethod:@"onIosSettingsRegistered" arguments:settingsDictionary]; [_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)){ - (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; NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo]; [JPUSHService handleRemoteNotification:userInfo];
[_channel invokeMethod:@"onReceiveNotification" arguments: [self jpushFormatAPNSDic:userInfo]]; [_channel invokeMethod:@"onReceiveNotification" arguments: [self jpushFormatAPNSDic:userInfo]];
}else{
JPLog(@"iOS10 前台收到本地通知:userInfo%@",userInfo);
} }
completionHandler(notificationTypes); completionHandler(notificationTypes);
} }
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler API_AVAILABLE(ios(10.0)){ - (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; NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo]; [JPUSHService handleRemoteNotification:userInfo];
[_channel invokeMethod:@"onOpenNotification" arguments: [self jpushFormatAPNSDic: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(); completionHandler();
} }
- (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info { - (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
JPLog(@"");
BOOL isEnabled = NO; BOOL isEnabled = NO;
if (status == JPAuthorizationStatusAuthorized) { if (status == JPAuthorizationStatusAuthorized) {
isEnabled = YES; isEnabled = YES;

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

Loading…
Cancel
Save