anypush
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -280,4 +280,7 @@ import { Service } from '../service'; | ||
export interface AppleServiceOptions { | ||
production: boolean; | ||
/** | ||
* Topic strings could be provided to determine production or sandbox. | ||
*/ | ||
production: boolean | string[]; | ||
/** | ||
* Key content. | ||
@@ -293,6 +296,6 @@ */ | ||
private providerTokenRefreshAt; | ||
private endpoint; | ||
constructor(options: AppleServiceOptions); | ||
push({ topic, token }: AppleTarget, { apns, ...message }: AppleMessage, data: object): Promise<void>; | ||
private getEndpoint; | ||
private getProviderToken; | ||
} |
@@ -37,15 +37,5 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "endpoint", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
const { production } = options; | ||
this.endpoint = production | ||
? 'https://api.push.apple.com' | ||
: 'https://api.sandbox.push.apple.com'; | ||
} | ||
async push({ topic, token }, { apns = {}, ...message }, data) { | ||
const { endpoint } = this; | ||
const endpoint = this.getEndpoint(topic); | ||
const providerToken = this.getProviderToken(); | ||
@@ -110,2 +100,11 @@ const request = HTTP2Wrapper.request(`${endpoint}/3/device/${token}`, { | ||
} | ||
getEndpoint(topic) { | ||
let { options: { production }, } = this; | ||
if (typeof production !== 'boolean') { | ||
production = production.includes(topic); | ||
} | ||
return production | ||
? 'https://api.push.apple.com' | ||
: 'https://api.sandbox.push.apple.com'; | ||
} | ||
getProviderToken() { | ||
@@ -112,0 +111,0 @@ const now = Date.now(); |
{ | ||
"name": "anypush", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "AnyPush", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/vilic/anypush.git", |
Sorry, the diff of this file is not supported yet
140038
3238