Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
javajuice1337 committed Mar 29, 2024
1 parent c856d17 commit 05702eb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/register/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const uuidv4 = require('uuid/v4');
const { register: registerGCM } = require('../gcm');
const registerFCM = require('../fcm');
const { installFCM, registerFCM } = require('../fcm');

module.exports = register;

async function register(senderId) {
async function register(config) {
// Should be unique by app - One GCM registration/token by app/appId
const appId = `wp:receiver.push.com#${uuidv4()}`;
const subscription = await registerGCM(appId);
const installation = await installFCM(config);
const result = await registerFCM({
token : subscription.token,
senderId,
appId,
...config,
authToken : installation.authToken.token,
token : subscription.token
});
// Need to be saved by the client
return Object.assign({}, result, { gcm : subscription });
Expand Down

0 comments on commit 05702eb

Please sign in to comment.