google-instanceid-batchimport

0.0.2 • Public • Published

google-instanceid-batchimport

Lightweight client implementing only the batchImport method of the Google Instance ID service. This is useful for mapping one or more (up to 100) APNs tokens to GCM/FCM tokens. See: https://developers.google.com/instance-id/reference/server#create_registration_tokens_for_apns_tokens

Installation

npm install --save google-instanceid-batchimport

Usage

const BatchImportService = require('google-instanceid-batchimport');
const service = BatchImportService(FCM_SERVER_KEY);
service.batchImport(
    'com.mydomain.myapp',
    true,
    [
        'apnstoken1',
        'apnstoken2',
        // ... etc    
    ]
).then(response => {
    if (response.status === 200) {
        return response.json();    
    }
    throw new Error(`Request returned ${response.status}`);
}).then(data => {
    for (let token of data.results) {
        console.log(`${token.apns_token} mapped to ${token.registration_token}`);    
    }
});

Package Sidebar

Install

npm i google-instanceid-batchimport

Weekly Downloads

2

Version

0.0.2

License

ISC

Unpacked Size

2.77 kB

Total Files

3

Last publish

Collaborators

  • wayne530