Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
514 stars 197 forks source link

Error: Push.Configure should not be called more than once! #278

Open ludovers opened 7 years ago

ludovers commented 7 years ago

I dont really understand the configuration of how to send a notification. I want to test the notifications on Android first.

So in my /client/main.js I've pasted the following:

import { Push } from 'meteor/raix:push';
import '/imports/startup/client';

Push.Configure({
  android: {
    senderID: MY SENDER ID,
    alert: true,
    badge: true,
    sound: true,
    vibrate: true,
    clearNotifications: true
    // icon: '',
    // iconColor: ''
  },
  // ios: {
  //   alert: true,
  //   badge: true,
  //   sound: true
  // }
});

In the root folder of my Meteor project I've created a mobile-config.js with the following code:

App.configurePlugin('phonegap-plugin-push', {
  SENDER_ID: MY SENDER ID
});

And in my /server/main.js I've got the following code:

import { Push } from 'meteor/raix:push';
import '/imports/startup/server';

Push.Configure({
  // apn: {
  //   certData: Assets.getText('apnDevCert.pem'),
  //   keyData: Assets.getText('apnDevKey.pem'),
  //   passphrase: 'xxxxxxxxx',
  //   production: true,
  //   //gateway: 'gateway.push.apple.com',
  // },
  gcm: {
    apiKey: 'MY API KEY',
    projectNumber: MY SENDER ID
  }
  // production: true,
  // 'sound' true,
  // 'badge' true,
  // 'alert' true,
  // 'vibrate' true,
  // 'sendInterval': 15000, Configurable interval between sending
  // 'sendBatchSize': 1, Configurable number of notifications to send per batch
  // 'keepNotifications': false,
//
});

But I get the error: Error: Push.Configure should not be called more than once!

What am I doing wrong?

LarsBuur commented 7 years ago

Post the contents of the files you are importing.

ludovers commented 7 years ago

In Client/main.js it just imports all files from imports/startup/client/index.js (which imports my complete client-side root), and Server/main.js it imports files from imports/startup/server/index.js, which imports my complete server-side root... Should I paste my entire root.. xD?

raix commented 7 years ago

@ludovers do you have any push.config.json files laying around? - the error happens if push is configured more than once, it's expected behaviour as a safeguard

ludovers commented 7 years ago

@raix Thank you sir! That solved the problem!