New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ionic2-jpush

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic2-jpush - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0-beta.1

45

dist/plugin-jpush.service.d.ts

@@ -8,6 +8,10 @@ import { Observable } from 'rxjs/Rx';

initJPushPlugin(): void;
setDebugMode(debug: boolean): Promise<{}>;
startJPushSDK(): Promise<{}>;
init(): Promise<{}>;
getRegistrationID(): Promise<{}>;
stopPush(): Promise<{}>;
resumePush(): Promise<{}>;
getRegistrationID(): Promise<{}>;
getUserNotificationSettings(): Promise<{}>;
setLatestNotificationNum(num?: number): Promise<{}>;
isPushStopped(): Promise<{}>;

@@ -23,6 +27,27 @@ /**

*
* @param tags
* @param data
* @returns {Promise<T>}
*/
setTags(tags: Array<any>): Promise<{}>;
setTags(data: string[] | {
sequence: number;
tags: string[];
}): Promise<{}>;
addTags(data: {
sequence: number;
tags: string[];
}): Promise<{}>;
deleteTags(data: {
sequence: number;
tags: string[];
}): Promise<{}>;
cleanTags(data: {
sequence: number;
}): Promise<{}>;
getAllTags(data: {
sequence: number;
}): Promise<{}>;
checkTagBindState(data: {
sequence: number;
tag: string;
}): Promise<{}>;
/**

@@ -33,3 +58,12 @@ *

*/
setAlias(alias: string): Promise<{}>;
setAlias(alias: string | {
sequence: number;
alias: string;
}): Promise<{}>;
deleteAlias(data: {
sequence: number;
}): Promise<{}>;
getAlias(data: {
sequence: number;
}): Promise<{}>;
/**

@@ -49,2 +83,4 @@ *

getApplicationIconBadgeNumber(): Promise<{}>;
setPushTime(days: number | null[], startHour: number, endHour: number): Promise<{}>;
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<{}>;
/**

@@ -73,2 +109,3 @@ *

backgroundNotification(): Observable<any>;
receiveRegistrationId(): Observable<any>;
}

@@ -5,4 +5,4 @@ import { Injectable } from '@angular/core';

function JPushService() {
this.jPushPlugin = window.plugins ? window.plugins.jPushPlugin || null : null;
this.warnText = '没有找到 jPushPlugin 对象 \n也许你是在浏览器环境下运行或者没有正确安装插件; \n如果没有在Platform 的 ready 方法中调用,也会出现这样的情况。\n了解:http://ionicframework.com/docs/v2/api/platform/Platform/';
this.initJPushPlugin();
}

@@ -16,4 +16,40 @@ JPushService.prototype.wrapEventObservable = function (event) {

JPushService.prototype.initJPushPlugin = function () {
this.jPushPlugin = window.plugins ? window.plugins.jPushPlugin || null : null;
if (window.plugins && window.plugins.jPushPlugin) {
this.jPushPlugin = window.plugins.jPushPlugin;
}
else if (window.JPush) {
this.jPushPlugin = window.JPush;
}
else {
this.jPushPlugin = null;
}
};
JPushService.prototype.setDebugMode = function (debug) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setDebugMode(debug);
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.startJPushSDK = function () {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.startJPushSDK();
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.init = function () {

@@ -33,2 +69,30 @@ var _this = this;

};
JPushService.prototype.stopPush = function () {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.stopPush();
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.resumePush = function () {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.resumePush();
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.getRegistrationID = function () {

@@ -54,3 +118,3 @@ var _this = this;

};
JPushService.prototype.stopPush = function () {
JPushService.prototype.getUserNotificationSettings = function () {
var _this = this;

@@ -60,4 +124,10 @@ this.initJPushPlugin();

if (_this.jPushPlugin) {
_this.jPushPlugin.stopPush();
resolve('ok');
_this.jPushPlugin.getUserNotificationSettings(function (result) {
if (result === 0) {
reject(result);
}
else {
resolve(result);
}
});
}

@@ -70,8 +140,9 @@ else {

};
JPushService.prototype.resumePush = function () {
JPushService.prototype.setLatestNotificationNum = function (num) {
var _this = this;
if (num === void 0) { num = 5; }
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.resumePush();
_this.jPushPlugin.setLatestNotificationNum(num);
resolve('ok');

@@ -127,12 +198,38 @@ }

*
* @param tags
* @param data
* @returns {Promise<T>}
*/
JPushService.prototype.setTags = function (tags) {
JPushService.prototype.setTags = function (data) {
var _this = this;
this.initJPushPlugin();
if (Array.isArray(data)) {
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setTags(data);
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
}
else if (typeof data === 'object') {
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setTags(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
}
};
JPushService.prototype.addTags = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setTags(tags);
resolve('ok');
_this.jPushPlugin.addTags(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}

@@ -145,2 +242,54 @@ else {

};
JPushService.prototype.deleteTags = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.deleteTags(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.cleanTags = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.cleanTags(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.getAllTags = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.getAllTags(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.checkTagBindState = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.checkTagBindState(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
/**

@@ -154,6 +303,32 @@ *

this.initJPushPlugin();
if (typeof alias === 'string') {
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setAlias(alias);
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
}
else if (typeof alias === 'object') {
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setAlias(alias, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
}
};
JPushService.prototype.deleteAlias = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setAlias(alias);
resolve('ok');
_this.jPushPlugin.deleteAlias(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}

@@ -166,2 +341,15 @@ else {

};
JPushService.prototype.getAlias = function (data) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.getAlias(data, function (res) { return resolve(res); }, function (error) { return reject(error); });
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
/**

@@ -234,2 +422,30 @@ *

};
JPushService.prototype.setPushTime = function (days, startHour, endHour) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setPushTime(days, startHour, endHour);
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
JPushService.prototype.setSilenceTime = function (startHour, startMinute, endHour, endMinute) {
var _this = this;
this.initJPushPlugin();
return new Promise(function (resolve, reject) {
if (_this.jPushPlugin) {
_this.jPushPlugin.setSilenceTime(startHour, startMinute, endHour, endMinute);
resolve('ok');
}
else {
console.warn(_this.warnText);
reject('没有找到 jPushPlugin');
}
});
};
/**

@@ -292,2 +508,5 @@ *

};
JPushService.prototype.receiveRegistrationId = function () {
return this.wrapEventObservable('jpush.receiveRegistrationId');
};
JPushService.decorators = [

@@ -294,0 +513,0 @@ { type: Injectable },

2

dist/plugin-jpush.service.metadata.json

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":1,"metadata":{"JPushService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"wrapEventObservable":[{"__symbolic":"method"}],"initJPushPlugin":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"getRegistrationID":[{"__symbolic":"method"}],"stopPush":[{"__symbolic":"method"}],"resumePush":[{"__symbolic":"method"}],"isPushStopped":[{"__symbolic":"method"}],"setTagsWithAlias":[{"__symbolic":"method"}],"setTags":[{"__symbolic":"method"}],"setAlias":[{"__symbolic":"method"}],"setBadge":[{"__symbolic":"method"}],"reSetBadge":[{"__symbolic":"method"}],"setApplicationIconBadgeNumber":[{"__symbolic":"method"}],"getApplicationIconBadgeNumber":[{"__symbolic":"method"}],"clearNotificationById":[{"__symbolic":"method"}],"clearAllNotification":[{"__symbolic":"method"}],"openNotification":[{"__symbolic":"method"}],"receiveNotification":[{"__symbolic":"method"}],"receiveMessage":[{"__symbolic":"method"}],"backgroundNotification":[{"__symbolic":"method"}]}}}}
{"__symbolic":"module","version":1,"metadata":{"JPushService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"wrapEventObservable":[{"__symbolic":"method"}],"initJPushPlugin":[{"__symbolic":"method"}],"setDebugMode":[{"__symbolic":"method"}],"startJPushSDK":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"stopPush":[{"__symbolic":"method"}],"resumePush":[{"__symbolic":"method"}],"getRegistrationID":[{"__symbolic":"method"}],"getUserNotificationSettings":[{"__symbolic":"method"}],"setLatestNotificationNum":[{"__symbolic":"method"}],"isPushStopped":[{"__symbolic":"method"}],"setTagsWithAlias":[{"__symbolic":"method"}],"setTags":[{"__symbolic":"method"}],"addTags":[{"__symbolic":"method"}],"deleteTags":[{"__symbolic":"method"}],"cleanTags":[{"__symbolic":"method"}],"getAllTags":[{"__symbolic":"method"}],"checkTagBindState":[{"__symbolic":"method"}],"setAlias":[{"__symbolic":"method"}],"deleteAlias":[{"__symbolic":"method"}],"getAlias":[{"__symbolic":"method"}],"setBadge":[{"__symbolic":"method"}],"reSetBadge":[{"__symbolic":"method"}],"setApplicationIconBadgeNumber":[{"__symbolic":"method"}],"getApplicationIconBadgeNumber":[{"__symbolic":"method"}],"setPushTime":[{"__symbolic":"method"}],"setSilenceTime":[{"__symbolic":"method"}],"clearNotificationById":[{"__symbolic":"method"}],"clearAllNotification":[{"__symbolic":"method"}],"openNotification":[{"__symbolic":"method"}],"receiveNotification":[{"__symbolic":"method"}],"receiveMessage":[{"__symbolic":"method"}],"backgroundNotification":[{"__symbolic":"method"}],"receiveRegistrationId":[{"__symbolic":"method"}]}}}}
{
"name": "ionic2-jpush",
"version": "0.0.5",
"version": "0.1.0-beta.1",
"description": "ionic2 jPush",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -7,4 +7,4 @@ /**

declare var plugins:any;
declare var document:any;
declare var plugins: any;
declare var document: any;

@@ -14,293 +14,539 @@ @Injectable()

private jPushPlugin = (<any>window).plugins ? (<any>window).plugins.jPushPlugin || null : null;
warnText:string = '没有找到 jPushPlugin 对象 \n也许你是在浏览器环境下运行或者没有正确安装插件; \n如果没有在Platform 的 ready 方法中调用,也会出现这样的情况。\n了解:http://ionicframework.com/docs/v2/api/platform/Platform/';
constructor () {
private jPushPlugin: any;
warnText: string = '没有找到 jPushPlugin 对象 \n也许你是在浏览器环境下运行或者没有正确安装插件; \n如果没有在Platform 的 ready 方法中调用,也会出现这样的情况。\n了解:http://ionicframework.com/docs/v2/api/platform/Platform/';
}
constructor() {
this.initJPushPlugin()
}
wrapEventObservable(event: string): Observable<any> {
return new Observable( (observer:any) => {
document.addEventListener(event, observer.next.bind(observer), false);
return () => document.removeEventListener(event, observer.next.bind(observer), false);
});
}
wrapEventObservable(event: string): Observable<any> {
return new Observable((observer: any) => {
document.addEventListener(event, observer.next.bind(observer), false);
return () => document.removeEventListener(event, observer.next.bind(observer), false);
});
}
initJPushPlugin() {
this.jPushPlugin = (<any>window).plugins ? (<any>window).plugins.jPushPlugin || null : null;
}
initJPushPlugin() {
if ((<any>window).plugins && (<any>window).plugins.jPushPlugin) {
this.jPushPlugin = (<any>window).plugins.jPushPlugin
} else if ((<any>window).JPush) {
this.jPushPlugin = (<any>window).JPush
} else {
this.jPushPlugin = null
}
}
init() {
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
setDebugMode(debug: boolean) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if(this.jPushPlugin){
this.jPushPlugin.init();
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
if (this.jPushPlugin) {
this.jPushPlugin.setDebugMode(debug);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
getRegistrationID(){
this.initJPushPlugin();
startJPushSDK() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
return new Promise((resolve,reject) =>{
if (this.jPushPlugin) {
this.jPushPlugin.startJPushSDK();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
if(this.jPushPlugin){
this.jPushPlugin.getRegistrationID( (id:any) => {
if(id){
resolve(id)
}else{
reject('获取ID失败')
}
} )
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
init() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.init();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
})
}
stopPush() {
this.initJPushPlugin();
stopPush(){
this.initJPushPlugin();
return new Promise((resolve, reject) => {
return new Promise((resolve,reject) =>{
if (this.jPushPlugin) {
this.jPushPlugin.stopPush();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
if(this.jPushPlugin){
this.jPushPlugin.stopPush();
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
resumePush() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.resumePush();
resumePush(){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.resumePush();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
getRegistrationID() {
this.initJPushPlugin();
isPushStopped(){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
return new Promise((resolve, reject) => {
if(this.jPushPlugin){
this.jPushPlugin.isPushStopped( (result:any) => {
if(result === 0 ){
resolve(true)
}else{
reject(false)
}
} )
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
if (this.jPushPlugin) {
this.jPushPlugin.getRegistrationID((id: any) => {
if (id) {
resolve(id)
} else {
reject('获取ID失败')
}
})
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
})
}
/**
*
* @param tags
* @param alias
* @returns {Promise<T>}
*/
setTagsWithAlias(tags:Array<any>,alias:string){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.setTagsWithAlias(tags,alias);
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
getUserNotificationSettings() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.getUserNotificationSettings((result: any) => {
if (result === 0) {
reject(result)
} else {
resolve(result)
}
})
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param tags
* @returns {Promise<T>}
*/
setTags(tags:Array<any>){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.setTags(tags);
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
setLatestNotificationNum(num = 5) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
/**
*
* @param alias
* @returns {Promise<T>}
*/
setAlias(alias:string){
this.initJPushPlugin();
if (this.jPushPlugin) {
this.jPushPlugin.setLatestNotificationNum(num);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.setAlias(alias);
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param value
* @returns {Promise<T>}
*/
setBadge(value:number){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.setBadge(value);
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
isPushStopped() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
}
if (this.jPushPlugin) {
this.jPushPlugin.isPushStopped((result: any) => {
if (result === 0) {
resolve(true)
} else {
reject(false)
}
})
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
reSetBadge(){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.reSetBadge();
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
})
}
})
}
/**
*
* @param tags
* @param alias
* @returns {Promise<T>}
*/
setTagsWithAlias(tags: Array<any>, alias: string) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setTagsWithAlias(tags, alias);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param value
* @returns {Promise<T>}
*/
setApplicationIconBadgeNumber(value:number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setApplicationIconBadgeNumber(value);
resolve('ok')
/**
*
* @param data
* @returns {Promise<T>}
*/
setTags(data: string[] | { sequence: number; tags: string[] }) {
this.initJPushPlugin();
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
if (Array.isArray(data)) {
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setTags(data);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
} else if (typeof data === 'object') {
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setTags(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
}
getApplicationIconBadgeNumber() {
this.initJPushPlugin();
addTags(data: { sequence: number; tags: string[] }) {
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.addTags(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
if(this.jPushPlugin){
this.jPushPlugin.getApplicationIconBadgeNumber( (num:any) => {
resolve(num)
} )
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
deleteTags(data: { sequence: number; tags: string[] }) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.deleteTags(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
})
}
cleanTags(data: { sequence: number }) {
this.initJPushPlugin();
/**
*
* @param id
* @returns {Promise<T>}
*/
clearNotificationById(id:number){
this.initJPushPlugin();
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.clearNotificationById(id);
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.cleanTags(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
}
getAllTags(data: { sequence: number }) {
this.initJPushPlugin();
clearAllNotification(){
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.getAllTags(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
return new Promise((resolve,reject) =>{
if(this.jPushPlugin){
this.jPushPlugin.clearAllNotification();
resolve('ok')
}else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
checkTagBindState(data: { sequence: number, tag: string }) {
this.initJPushPlugin();
}
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.checkTagBindState(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @returns {Observable<any>}
*/
openNotification(){
return this.wrapEventObservable('jpush.openNotification');
}
/**
*
* @param alias
* @returns {Promise<T>}
*/
setAlias(alias: string | { sequence: number; alias: string }) {
this.initJPushPlugin();
if (typeof alias === 'string') {
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setAlias(alias);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
} else if (typeof alias === 'object') {
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setAlias(
alias,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @returns {Observable<any>}
*/
receiveNotification(){
return this.wrapEventObservable('jpush.receiveNotification');
}
}
/**
*
* @returns {Observable<any>}
*/
receiveMessage(){
return this.wrapEventObservable('jpush.receiveMessage');
}
deleteAlias(data: { sequence: number }) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.deleteAlias(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
backgroundNotification(){
return this.wrapEventObservable('jpush.backgroundNotification');
}
getAlias(data: { sequence: number }) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.getAlias(
data,
(res: any) => resolve(res),
(error: any) => reject(error)
);
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param value
* @returns {Promise<T>}
*/
setBadge(value: number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setBadge(value);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
reSetBadge() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.reSetBadge();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param value
* @returns {Promise<T>}
*/
setApplicationIconBadgeNumber(value: number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setApplicationIconBadgeNumber(value);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
getApplicationIconBadgeNumber() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.getApplicationIconBadgeNumber((num: any) => {
resolve(num)
})
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
setPushTime(days: number | null[], startHour: number, endHour: number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setPushTime(days, startHour, endHour);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.setSilenceTime(startHour, startMinute, endHour, endMinute);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @param id
* @returns {Promise<T>}
*/
clearNotificationById(id: number) {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.clearNotificationById(id);
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
clearAllNotification() {
this.initJPushPlugin();
return new Promise((resolve, reject) => {
if (this.jPushPlugin) {
this.jPushPlugin.clearAllNotification();
resolve('ok')
} else {
console.warn(this.warnText);
reject('没有找到 jPushPlugin');
}
})
}
/**
*
* @returns {Observable<any>}
*/
openNotification() {
return this.wrapEventObservable('jpush.openNotification');
}
/**
*
* @returns {Observable<any>}
*/
receiveNotification() {
return this.wrapEventObservable('jpush.receiveNotification');
}
/**
*
* @returns {Observable<any>}
*/
receiveMessage() {
return this.wrapEventObservable('jpush.receiveMessage');
}
backgroundNotification() {
return this.wrapEventObservable('jpush.backgroundNotification');
}
receiveRegistrationId() {
return this.wrapEventObservable('jpush.receiveRegistrationId');
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc