Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneSignalPushAdapter Says Push Was Sent to X Devices But Non Of My Devices Gets the Push #894

Closed
432player opened this issue Mar 7, 2016 · 6 comments

Comments

@432player
Copy link

We are using the Push Massaging through a Cloud Code.
Found Several examples online..

According to this part of the wiki, we need to add OneSignalPushAdapter (or any other adapter) to send push notifications successfully.

The OneSignalPushAdapter logs say It sent the push notifications to 1,5,9,15 devices, according to our specifications, but non of our devices just don't get any push message...
No Error, No Failure, nothing...

This is our server code:

// Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

//Mailgun - reset password
var SimpleMailgunAdapter = require('parse-server/lib/Adapters/Email/SimpleMailgunAdapter');
var simpleMailgunAdapter = new SimpleMailgunAdapter({
  apiKey: process.env.MAILGUN_KEY,
  domain: process.env.DOMAIN,
  fromAddress: process.env.MAILGUN_FROM_ADDRESS
});
//Push Adapter
var OneSignalPushAdapter = require('parse-server/lib/Adapters/Push/OneSignalPushAdapter');
var oneSignalPushAdapter = new OneSignalPushAdapter({
  oneSignalAppId:process.env.ONE_SIGNAL_APP_ID,
  oneSignalApiKey:process.env.ONE_SIGNAL_REST_API_KEY
});
//Server Part
var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  appName: 'Medidate',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337',  // Don't forget to change to https if needed
  publicServerURL: process.env.PUBLIC_SERVER_URL,
  emailAdapter: simpleMailgunAdapter,
  push: {
     adapter: oneSignalPushAdapter
  },
  // push: pushConfig,
  // push: {
    // android: {
    //  senderId: process.env.GCM_SENDER_ID, // The Sender ID of GCM
    //  apiKey: process.env.GCM_API_KEY // The Server API Key of GCM
    //  }
    //  ,
    // ios: {
    //  pdx: __dirname + '/ios_push/Medidate_prod_p12_new.p12', // the path and filename to the .p12 file you exported earlier. 
    //  bundleId: process.env.IOS_PUSH_BUNDLEID, // The bundle identifier associated with your app
    //  production: true
    //  }
    // }
  // ,
  // customPages: {
  //   invalidLink: process.env.SERVER_URL + 'invalid_link.html',
  //   verifyEmailSuccess: process.env.SERVER_URL + 'verify_email_success.html',
  //   choosePassword: process.env.SERVER_URL + 'views/choose_password',
  //   passwordResetSuccess: process.env.SERVER_URL + 'password_reset_success.html'
  // }
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a web site.');
});

var port = process.env.PORT || 1337;
app.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

As you can see, we have also tried a different approach, to use the regular push configurations (commented) but we can't figure out what should we do with this JAVA code(Android client side) part in many of the GCM tutorials online:
// Make a call to Instance API

InstanceID instanceID = InstanceID.getInstance(this);
        String senderId = getResources().getString(R.string.gcm_defaultSenderId);
        try {
            // request token that will be used by the server to send push notifications
            String token = instanceID.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            Log.d(TAG, "GCM Registration Token: " + token);

            // pass along this data
            sendRegistrationToServer(token);
        } catch (IOException e) {
            e.printStackTrace();
        }

We can't figure out how to use this token in our parse server...
In this alternative we get the notorious "MismatchSenderId" (we triple checked our server key and project id/sender id)
And we think it might be related to the JAVA code snippet above.

Are we missing any configuration in any of the Cloud Push alternatives?
Do we need to implement OneSignal SDK in our client side?

P.S
We don't get any errors in the Cloud Code push function part...

Thanks in advance.

@gdeglin
Copy link
Contributor

gdeglin commented Mar 8, 2016

@432player (I help work on OneSignal). This sounds like it might be an issue with your OneSignal configuration, and not with ParsePlatform or the OneSignalPushAdapter. Please get in touch with us at [email protected]

@flovilmart
Copy link
Contributor

I'll close hoping @gdeglin gets you up and running with one signal!

@mymanga
Copy link

mymanga commented May 27, 2016

Please post here for us with the same issue

@MattiaConfalonieri
Copy link

Same problem here, any solution?

@432player
Copy link
Author

I don't really remember what the problem was for this exact issue.
But what we had to do ourselves was once we got the token from onesignal on registry we needed to save it to the installation ourselves because Parse and OneSignle didn't create matching tokens and that's why the device was registered but didn't get any pushes.

Hope that hint helps.
Hint number 2, you can't save the token to your installation, only through a cloudcode method :)

Hope that helps

@MattiaConfalonieri
Copy link

@432player you right, the problem is that for Android OneSignal adapter need OneSignal sdk installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants