Search code examples
androidparse-platformpush-notificationandroid-notificationsparse-server

Push not working with Parse-server hosted on Localhost/amazon beanstalk


In my AfterSave I fire a push and I can see Success statements being printed in CloudCode but nothing being received on my IOS or Android device.

Here is the Cloudcode:

    function senderPush(instalationId, receiverName, receiverNumber, message, status ) {
    var query = new Parse.Query(Parse.Installation);
    query.equalTo("installationId", instalationId);
    Push.send({
        where: query,
        data: {
            header: "Status : " + status ,
            ...
            badge: "Increment",
            message : message,
            status : status,
        }
    },{
        success: function() {
            console.log("notification sent");
        },
        error: function(error) {
            console.log("Error sending senderPush: " + error);
        },
        useMasterKey: true
    });
    }

Here is AndroidManifest.xml :

    <receiver android:name="com.Myapplication.receiver.StatusReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.Myapplication.receiver.UPDATE_STATUS" />
        </intent-filter>
    </receiver>
    <service
        android:name="com.Myapplication.util.VoiceCommandService"
        android:exported="false">
    </service>
    <meta-data android:name="com.parse.push.gcm_sender_id" android:value="id:XXXXXXXX" />'

Here is my Application.Java :

    Parse.addParseNetworkInterceptor(new ParseLogInterceptor());
        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                        .applicationId(APPLICATION_ID)
                        .server(BRConstants.MY_IP_ADDRESS_SERVER).build()
        );

Everything else is working fine. But push doesn't seem to work. No Errors, nothing. When I send data from Android, I am getting this message in Console which has request but no response :

    GCM request and response {"request":{"params":
    {"priority":"normal","data":{"time":"2016-07-
    18T19:50:01.949Z","push_id":"2SxLKSeThF","data":"{\"header\":\"Status :
     Cancelled\",\"alertMessage\":\".....
    MYDATA.......\":\"Cancelled\"}"}}}}

Not sure what am I missing here.


Solution

  • You get 2 keys from GCM.

    One for the Android device and another is for the server. In the parse, you need to put the server key.