mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c3228848b | |||
| 585e2a5084 | |||
| c726477cfb | |||
| 3f00143a5a | |||
| f5ea2b5b10 | |||
| 266d0cb28f |
@@ -1,7 +1,7 @@
|
|||||||
# JPush PhoneGap / Cordova Plugin
|
# JPush PhoneGap / Cordova Plugin
|
||||||
|
|
||||||
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||||
|
|
||||||
|
|||||||
@@ -437,9 +437,7 @@ window.JPush.clearAllLocalNotifications()
|
|||||||
|
|
||||||
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
|
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
|
||||||
|
|
||||||
### 点击本地通知横幅启动 App
|
|
||||||
|
|
||||||
监听 `jpush.startLocalNotification` 事件。
|
|
||||||
|
|
||||||
## 页面的统计
|
## 页面的统计
|
||||||
|
|
||||||
@@ -726,10 +724,6 @@ window.JPush.getUserNotificationSettings(callback)
|
|||||||
|
|
||||||
[获取自定义消息内容](#获取自定义消息内容)
|
[获取自定义消息内容](#获取自定义消息内容)
|
||||||
|
|
||||||
### jpush.startLocalNotification
|
|
||||||
|
|
||||||
[点击本地通知横幅启动 App](#点击本地通知横幅启动-app)
|
|
||||||
|
|
||||||
### jpush.receiveLocalNotification
|
### jpush.receiveLocalNotification
|
||||||
|
|
||||||
[iOS 10 before 收到本地通知](#ios-10-before-收到本地通知)
|
[iOS 10 before 收到本地通知](#ios-10-before-收到本地通知)
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "3.2.5",
|
"version": "3.2.7",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
|||||||
+8
-1
@@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="3.2.5">
|
version="3.2.7">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@@ -195,6 +195,13 @@
|
|||||||
android:name="cn.jpush.android.service.DataProvider"
|
android:name="cn.jpush.android.service.DataProvider"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
|
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||||
|
<category android:name="$PACKAGE_NAME"></category>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<!-- Required. Enable it you can get statistics data with channel -->
|
<!-- Required. Enable it you can get statistics data with channel -->
|
||||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" />
|
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" />
|
||||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
||||||
|
|||||||
@@ -38,19 +38,28 @@
|
|||||||
NSDictionary *_launchOptions;
|
NSDictionary *_launchOptions;
|
||||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil];
|
||||||
|
|
||||||
if (notification) {
|
if (notification) {
|
||||||
if (notification.userInfo) {
|
if (notification.userInfo) {
|
||||||
NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
||||||
if (userInfo1.count > 0) {
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo1 repeats:YES];
|
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:)
|
||||||
|
userInfo:[notification.userInfo
|
||||||
|
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] repeats:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
||||||
if (userInfo2.count > 0) {
|
UILocalNotification *localNotification = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
|
||||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo2 repeats:YES];
|
|
||||||
|
NSDictionary* localNotificationEvent = @{@"content":localNotification.alertBody,
|
||||||
|
@"badge": @(localNotification.applicationIconBadgeNumber),
|
||||||
|
@"extras":localNotification.userInfo,
|
||||||
|
};
|
||||||
|
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:localNotificationEvent repeats:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JPUSHService setDebugMode];
|
[JPUSHService setDebugMode];
|
||||||
|
|
||||||
NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"];
|
NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"];
|
||||||
@@ -70,6 +79,11 @@ NSDictionary *_launchOptions;
|
|||||||
[JPushPlugin setupJPushSDK:_launchOptions];
|
[JPushPlugin setupJPushSDK:_launchOptions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)jpushSDKDidLoginNotification {
|
||||||
|
NSDictionary *event = @{@"registrationId": JPUSHService.registrationID};
|
||||||
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
|
||||||
|
}
|
||||||
|
|
||||||
-(void)registerForRemoteNotification{
|
-(void)registerForRemoteNotification{
|
||||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||||
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ static NSString *const JPushDocumentEvent_OpenNotification = @"openNoti
|
|||||||
static NSString *const JPushDocumentEvent_BackgroundNotification = @"backgroundNotification";
|
static NSString *const JPushDocumentEvent_BackgroundNotification = @"backgroundNotification";
|
||||||
static NSString *const JPushDocumentEvent_SetTagsWithAlias = @"setTagsWithAlias";
|
static NSString *const JPushDocumentEvent_SetTagsWithAlias = @"setTagsWithAlias";
|
||||||
static NSString *const JPushDocumentEvent_ReceiveMessage = @"receiveMessage";
|
static NSString *const JPushDocumentEvent_ReceiveMessage = @"receiveMessage";
|
||||||
static NSString *const JPushDocumentEvent_StartLocalNotification = @"startLocalNotification";
|
|
||||||
static NSString *const JPushDocumentEvent_ReceiveLocalNotification = @"receiveLocalNotification";
|
static NSString *const JPushDocumentEvent_ReceiveLocalNotification = @"receiveLocalNotification";
|
||||||
|
|
||||||
|
static NSString *const JPushDocumentEvent_receiveRegistrationId = @"receiveRegistrationId";
|
||||||
|
|||||||
Reference in New Issue
Block a user