diff --git a/README.md b/README.md index d74d854..c350fab 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin) [![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)]() -[![release](https://img.shields.io/badge/release-3.1.0-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) +[![release](https://img.shields.io/badge/release-3.1.3-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) [![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin) [![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1) diff --git a/package.json b/package.json index 7a58c99..9bfdaa4 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,38 @@ { - "name": "jpush-phonegap-plugin", - "version": "3.1.2", - "description": "JPush for cordova plugin", - "cordova": { - "id": "jpush-phonegap-plugin", - "platforms": [ - "ios", - "android" - ] - }, - "repository": { - "type": "git", - "url": "git+https://github.com/jpush/jpush-phonegap-plugin.git" - }, - "keywords": [ - "JPush", - "push", - "Push", - "ecosystem:cordova", - "cordova-ios", - "cordova-android" - ], - "engines": [ - { - "name": "cordova", - "version": ">=3.0" - } - ], - "peerDependencies": { - "cordova-plugin-device": ">=1.0.0", - "cordova-plugin-jcore": "1.1.1" - }, - "author": "JiGuang", - "license": "MIT", - "bugs": { - "url": "https://github.com/jpush/jpush-phonegap-plugin/issues" - }, - "homepage": "https://github.com/jpush/jpush-phonegap-plugin#readme" -} + "name": "jpush-phonegap-plugin", + "version": "3.1.3", + "description": "JPush for cordova plugin", + "cordova": { + "id": "jpush-phonegap-plugin", + "platforms": [ + "ios", + "android" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jpush/jpush-phonegap-plugin.git" + }, + "keywords": [ + "JPush", + "push", + "Push", + "ecosystem:cordova", + "cordova-ios", + "cordova-android" + ], + "engines": [{ + "name": "cordova", + "version": ">=3.0" + }], + "peerDependencies": { + "cordova-plugin-device": ">=1.0.0", + "jcore-cordova-plugin": ">=1.1.1" + }, + "author": "JiGuang", + "license": "MIT", + "bugs": { + "url": "https://github.com/jpush/jpush-phonegap-plugin/issues" + }, + "homepage": "https://github.com/jpush/jpush-phonegap-plugin#readme" +} \ No newline at end of file diff --git a/plugin.xml b/plugin.xml index be50de1..9c4e32a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.1.3"> JPush Plugin JPush for cordova plugin diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index 862b1e7..1d8af8b 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -28,29 +28,27 @@ return [self init_plus]; } -NSDictionary *_launchOptions; +-(void)fireOpenNotification:(NSTimer*)timer{ + if (SharedJPushPlugin) { + [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[timer.userInfo toJsonString]]; + [timer invalidate]; + } +} +NSDictionary *_launchOptions; -(void)applicationDidLaunch:(NSNotification *)notification{ + if (notification) { if (notification.userInfo) { NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (userInfo1.count > 0) { - [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) { - if (SharedJPushPlugin) { - [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo1 toJsonString]]; - [timer invalidate]; - } - }]; + [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo1 repeats:YES]; } + NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (userInfo2.count > 0) { - [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) { - if (SharedJPushPlugin) { - [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo2 toJsonString]]; - [timer invalidate]; - } - }]; + [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo2 repeats:YES]; } } [JPUSHService setDebugMode]; @@ -64,7 +62,6 @@ NSDictionary *_launchOptions; if (![delay boolValue]) { [self startJPushSDK]; } - } }