Sending Push Notification to device using parse4j in java

364 views Asked by At

I am using parse4j library for server side coding and on client side I have iOS device. Now I want to send the push notification from my web browser page I developed in JAVA in which I am using parse4j library to communicate with iOS device through Parse cloud. I am using gwt for coding the server side.

public void sendPushtoIOS() {
    Parse.initialize("appId", "restApiId");
    ParsePush parsePushObj = new ParsePush();
    parsePushObj.sendInBackground("hello from server",null);
}

I am trying to send the notification with the above code, but nothing happens and iOS device doesn't receive any notification. Please could someone guide the code I written is correct or not, If not, how can I send the notification then?

3

There are 3 answers

0
kingspeech On

As far as I understand correct, you are using the Parse4j library to send Push Notification. Did you control the current version of parse4j if it can send Push notification? Or it is pending enhancement? One suggestion; in order to send push notification write a cloud code and trigger this cloud code from parse4j. Then cloud code will send the Push notification.

Hope this helps, Regards.

0
SANDEEP On
try {
    String rawJSON = "{\"aps\":{\"alert\":\""+"your message"+"\"},\"alerts\":{\"others\":\""+others+"\"}}";
    PushNotificationPayload payload=PushNotificationPayload.fromJSON(rawJSON);
    Push.payload(payload, "path of certificate.p12", password,false, appleDeviceToken);
}
catch (Exception e) {

}
0
Bagdat On

This library works fine. You can check pushes in parse dashboard, most likely you collected push requests. The only problem was that library works with channels. Maybe you do not set channels. If you want to work with conditions, add this lines of code in library

JSONObject local = new JSONObject();
local.put("deviceType", "android");
data.put("where", local);

and remove

data.put("channel", "");
data.put("channels", new JSONArray(this.channelSet));

all of these changes must be done in method getJSONData() in class ParsePush

instead of android you can set your devices