Merge branch 'ionic' into dev

This commit is contained in:
Hevin 2017-12-11 13:21:35 +08:00
commit 2d81c7800b
12 changed files with 614 additions and 3 deletions

View File

@ -379,7 +379,7 @@ window.JPush.addLocalNotificationForIOS(delayTime, content, badge, notificationI
#### 参数说明
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可。
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可,单位为秒
- content: 本地推送需要显示的内容。
- badge: 角标的数字。如果不需要改变角标传-1。数值类型或纯数字的字符型均可。
- notificationID: 本地推送标识符,字符串。

BIN
example/js/.DS_Store vendored

Binary file not shown.

171
index.ts Normal file
View File

@ -0,0 +1,171 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
import { Injectable } from '@angular/core';
export interface TagOptions {
sequence: number;
tags?: Array<string>;
}
export interface AliasOptions {
sequence: number;
alias?: string;
}
@Plugin({
pluginName: 'JPush',
plugin: 'jpush-phonegap-plugin',
pluginRef: 'plugins.jPushPlugin',
repo: 'https://github.com/jpush/jpush-phonegap-plugin',
install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
installVariables: ['APP_KEY'],
platforms: ['Android', 'iOS']
})
@Injectable()
export class JPush extends IonicNativePlugin {
@Cordova()
init(): Promise<any> { return; }
@Cordova()
setDebugMode(enable: boolean): Promise<any> { return; }
@Cordova()
getRegistrationID(): Promise<any> { return; }
@Cordova()
stopPush(): Promise<any> { return; }
@Cordova()
resumePush(): Promise<any> { return; }
@Cordova()
isPushStopped(): Promise<any> { return; }
@Cordova()
setTags(params: TagOptions): Promise<any> { return; }
@Cordova()
addTags(params: TagOptions): Promise<any> { return; }
@Cordova()
deleteTags(params: TagOptions): Promise<any> { return; }
@Cordova()
cleanTags(params: TagOptions): Promise<any> { return; }
@Cordova()
getAllTags(params: TagOptions): Promise<any> { return; }
/**
* @param params { sequence: number, tag: string }
*/
@Cordova()
checkTagBindState(params: object): Promise<any> { return; }
@Cordova()
setAlias(params: AliasOptions): Promise<any> { return; }
@Cordova()
deleteAlias(params: AliasOptions): Promise<any> { return; }
@Cordova()
getAlias(params: AliasOptions): Promise<any> { return; }
/**
* Determinate whether the application notification has been opened.
*
* iOS: 0: closed; >1: opened.
* UIRemoteNotificationTypeNone = 0,
* UIRemoteNotificationTypeBadge = 1 << 0,
* UIRemoteNotificationTypeSound = 1 << 1,
* UIRemoteNotificationTypeAlert = 1 << 2,
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
*
* Android: 0: closed; 1: opened.
*/
@Cordova()
getUserNotificationSettings(): Promise<any> { return; }
@Cordova()
clearLocalNotifications(): Promise<any> { return; }
// iOS API - start
@Cordova()
setBadge(badge: number): Promise<any> { return; }
@Cordova()
resetBadge(): Promise<any> { return; }
@Cordova()
setApplicationIconBadgeNumber(badge: number): Promise<any> { return; }
@Cordova()
getApplicationIconBadgeNumber(): Promise<any> { return; }
@Cordova()
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: string): Promise<any> { return; }
@Cordova()
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any> { return; }
@Cordova()
addDismissActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
@Cordova()
addNotificationActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
@Cordova()
setLocation(latitude: number, longitude: number): Promise<any> { return; }
@Cordova()
startLogPageView(pageName: string): Promise<any> { return; }
@Cordova()
stopLogPageView(pageName: string): Promise<any> { return; }
@Cordova()
beginLogPageView(pageName: string, duration: number): Promise<any> { return; }
// iOS API - end
// Android API - start
@Cordova()
getConnectionState(): Promise<any> { return; }
@Cordova()
setBasicPushNotificationBuilder(): Promise<any> { return; }
@Cordova()
setCustomPushNotificationBuilder(): Promise<any> { return; }
@Cordova()
clearAllNotification(): Promise<any> { return; }
@Cordova()
clearNotificationById(id: number): Promise<any> { return; }
@Cordova()
setLatestNotificationNum(num: number): Promise<any> { return; }
@Cordova()
addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any> { return; }
@Cordova()
removeLocalNotification(notificationId: number): Promise<any> { return; }
@Cordova()
reportNotificationOpened(msgId: number): Promise<any> { return; }
@Cordova()
requestPermission(): Promise<any> { return; }
@Cordova()
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any> { return; }
@Cordova()
setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any> { return; }
// Android API - end
}

1
ionic/example Submodule

@ -0,0 +1 @@
Subproject commit 148e087db2e678772a09fa83d3cff17c496acbb6

67
ionic/jpush/index.d.ts vendored Normal file
View File

@ -0,0 +1,67 @@
import { IonicNativePlugin } from '@ionic-native/core';
export interface TagOptions {
sequence: number;
tags?: Array<string>;
}
export interface AliasOptions {
sequence: number;
alias?: string;
}
export declare class JPush extends IonicNativePlugin {
init(): Promise<any>;
setDebugMode(enable: boolean): Promise<any>;
getRegistrationID(): Promise<any>;
stopPush(): Promise<any>;
resumePush(): Promise<any>;
isPushStopped(): Promise<any>;
setTags(params: TagOptions): Promise<any>;
addTags(params: TagOptions): Promise<any>;
deleteTags(params: TagOptions): Promise<any>;
cleanTags(params: TagOptions): Promise<any>;
getAllTags(params: TagOptions): Promise<any>;
/**
* @param params { sequence: number, tag: string }
*/
checkTagBindState(params: object): Promise<any>;
setAlias(params: AliasOptions): Promise<any>;
deleteAlias(params: AliasOptions): Promise<any>;
getAlias(params: AliasOptions): Promise<any>;
/**
* Determinate whether the application notification has been opened.
*
* iOS: 0: closed; >1: opened.
* UIRemoteNotificationTypeNone = 0,
* UIRemoteNotificationTypeBadge = 1 << 0,
* UIRemoteNotificationTypeSound = 1 << 1,
* UIRemoteNotificationTypeAlert = 1 << 2,
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
*
* Android: 0: closed; 1: opened.
*/
getUserNotificationSettings(): Promise<any>;
clearLocalNotifications(): Promise<any>;
setBadge(badge: number): Promise<any>;
resetBadge(): Promise<any>;
setApplicationIconBadgeNumber(badge: number): Promise<any>;
getApplicationIconBadgeNumber(): Promise<any>;
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, notificationId: number, extras?: string): Promise<any>;
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any>;
addDismissActions(actions: Array<object>, categoryId: string): Promise<any>;
addNotificationActions(actions: Array<object>, categoryId: string): Promise<any>;
setLocation(latitude: number, longitude: number): Promise<any>;
startLogPageView(pageName: string): Promise<any>;
stopLogPageView(pageName: string): Promise<any>;
beginLogPageView(pageName: string, duration: number): Promise<any>;
getConnectionState(): Promise<any>;
setBasicPushNotificationBuilder(): Promise<any>;
setCustomPushNotificationBuilder(): Promise<any>;
clearAllNotification(): Promise<any>;
clearNotificationById(id: number): Promise<any>;
setLatestNotificationNum(num: number): Promise<any>;
addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any>;
removeLocalNotification(notificationId: number): Promise<any>;
reportNotificationOpened(msgId: number): Promise<any>;
requestPermission(): Promise<any>;
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any>;
setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any>;
}

352
ionic/jpush/index.js Normal file
View File

@ -0,0 +1,352 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
import { Injectable } from '@angular/core';
var JPush = (function (_super) {
__extends(JPush, _super);
function JPush() {
return _super !== null && _super.apply(this, arguments) || this;
}
JPush.prototype.init = function () { return; };
JPush.prototype.setDebugMode = function (enable) { return; };
JPush.prototype.getRegistrationID = function () { return; };
JPush.prototype.stopPush = function () { return; };
JPush.prototype.resumePush = function () { return; };
JPush.prototype.isPushStopped = function () { return; };
JPush.prototype.setTags = function (params) { return; };
JPush.prototype.addTags = function (params) { return; };
JPush.prototype.deleteTags = function (params) { return; };
JPush.prototype.cleanTags = function (params) { return; };
JPush.prototype.getAllTags = function (params) { return; };
/**
* @param params { sequence: number, tag: string }
*/
JPush.prototype.checkTagBindState = function (params) { return; };
JPush.prototype.setAlias = function (params) { return; };
JPush.prototype.deleteAlias = function (params) { return; };
JPush.prototype.getAlias = function (params) { return; };
/**
* Determinate whether the application notification has been opened.
*
* iOS: 0: closed; >1: opened.
* UIRemoteNotificationTypeNone = 0,
* UIRemoteNotificationTypeBadge = 1 << 0,
* UIRemoteNotificationTypeSound = 1 << 1,
* UIRemoteNotificationTypeAlert = 1 << 2,
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
*
* Android: 0: closed; 1: opened.
*/
JPush.prototype.getUserNotificationSettings = function () { return; };
JPush.prototype.clearLocalNotifications = function () { return; };
// iOS API - start
JPush.prototype.setBadge = function (badge) { return; };
JPush.prototype.resetBadge = function () { return; };
JPush.prototype.setApplicationIconBadgeNumber = function (badge) { return; };
JPush.prototype.getApplicationIconBadgeNumber = function () { return; };
JPush.prototype.addLocalNotificationForIOS = function (delayTime, content, badge, notificationId, extras) { return; };
JPush.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (identifierKey) { return; };
JPush.prototype.addDismissActions = function (actions, categoryId) { return; };
JPush.prototype.addNotificationActions = function (actions, categoryId) { return; };
JPush.prototype.setLocation = function (latitude, longitude) { return; };
JPush.prototype.startLogPageView = function (pageName) { return; };
JPush.prototype.stopLogPageView = function (pageName) { return; };
JPush.prototype.beginLogPageView = function (pageName, duration) { return; };
// iOS API - end
// Android API - start
JPush.prototype.getConnectionState = function () { return; };
JPush.prototype.setBasicPushNotificationBuilder = function () { return; };
JPush.prototype.setCustomPushNotificationBuilder = function () { return; };
JPush.prototype.clearAllNotification = function () { return; };
JPush.prototype.clearNotificationById = function (id) { return; };
JPush.prototype.setLatestNotificationNum = function (num) { return; };
JPush.prototype.addLocalNotification = function (builderId, content, title, notificationId, broadcastTime, extras) { return; };
JPush.prototype.removeLocalNotification = function (notificationId) { return; };
JPush.prototype.reportNotificationOpened = function (msgId) { return; };
JPush.prototype.requestPermission = function () { return; };
JPush.prototype.setSilenceTime = function (startHour, startMinute, endHour, endMinute) { return; };
JPush.prototype.setPushTime = function (weekdays, startHour, endHour) { return; };
// Android API - end
JPush.decorators = [
{ type: Injectable },
];
/** @nocollapse */
JPush.ctorParameters = function () { return []; };
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "init", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Boolean]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setDebugMode", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "getRegistrationID", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "stopPush", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "resumePush", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "isPushStopped", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setTags", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addTags", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "deleteTags", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "cleanTags", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "getAllTags", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "checkTagBindState", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setAlias", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "deleteAlias", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], JPush.prototype, "getAlias", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "getUserNotificationSettings", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "clearLocalNotifications", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setBadge", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "resetBadge", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setApplicationIconBadgeNumber", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "getApplicationIconBadgeNumber", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, String, Number, Number, String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addLocalNotificationForIOS", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "deleteLocalNotificationWithIdentifierKeyInIOS", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addDismissActions", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addNotificationActions", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setLocation", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "startLogPageView", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "stopLogPageView", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "beginLogPageView", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "getConnectionState", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "setBasicPushNotificationBuilder", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "setCustomPushNotificationBuilder", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "clearAllNotification", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "clearNotificationById", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setLatestNotificationNum", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, String, String, Number, Number, String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addLocalNotification", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "removeLocalNotification", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "reportNotificationOpened", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], JPush.prototype, "requestPermission", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, Number, Number, Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setSilenceTime", null);
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array, Number, Number]),
__metadata("design:returntype", Promise)
], JPush.prototype, "setPushTime", null);
JPush = __decorate([
Plugin({
pluginName: 'JPush',
plugin: 'jpush-phonegap-plugin',
pluginRef: 'plugins.jPushPlugin',
repo: 'https://github.com/jpush/jpush-phonegap-plugin',
install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
installVariables: ['APP_KEY'],
platforms: ['Android', 'iOS']
})
], JPush);
return JPush;
}(IonicNativePlugin));
export { JPush };
//# sourceMappingURL=index.js.map

1
ionic/jpush/index.js.map Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

18
ionic/jpush/package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "@jiguang-ionic/jpush",
"version": "1.0.0",
"description": "JPush support for ionic-native",
"module": "index.js",
"typings": "index.d.ts",
"author": "hevin",
"license": "MIT",
"peerDependencies": {
"@ionic-native/core": "^4.2.0",
"@angular/core": "*",
"rxjs": "^5.0.1"
},
"repository": {
"type": "git",
"url": "https://github.com/jpush/jpush-phonegap-plugin"
}
}

View File

@ -96,6 +96,7 @@ public class JPushEventReceiver extends JPushMessageReceiver {
} catch (JSONException e) {
e.printStackTrace();
}
callback.success(resultJson);
} else {
try {
@ -103,7 +104,6 @@ public class JPushEventReceiver extends JPushMessageReceiver {
} catch (JSONException e) {
e.printStackTrace();
}
callback.error(resultJson);
}

View File

@ -241,7 +241,7 @@
CDVPluginResult* result;
if (iResCode == 0) {
[dic setObject:[iTags allObjects] forKey:@"tags"];
dic[@"tag"] = tag;
[dic setObject:[NSNumber numberWithBool:isBind] forKey:@"isBind"];
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic];
} else {