Can't push message to android app, how to debug it?
Hi, I start my parse-server with pm2, and the configurtion is as below , "senderId" and "apiKey" are not full.
{
"apps" :
[
{
"name" : "app_name",
"script" : "/usr/bin/parse-server",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse/parse_test/parse-server",
"env":
{
"PARSE_SERVER_DATABASE_URI": "mongodb://localhost:27017/parse_dev",
"PARSE_SERVER_APPLICATION_ID": "myAppId",
"PARSE_SERVER_MASTER_KEY": "123",
"PORT": "1337",
"PARSE_SERVER_MOUNT_PATH": "/1",
"PARSE_SERVER_URL": "http://myip:1337/parse",
"VERBOSE":1,
"PARSE_SERVER_PUSH":
{
"android":
{
"senderId":"127405",
"apiKey":"AIzaSyAI"
}
}
}
}
]
}
senderId is my project id, and apiKey is my Server key (auto created by Google Service);
when I send push message request by dashboard or by creating a post request, my android app can't receive any message, but nothing wrong i can find.
post request as follow:
curl -X POST -H "X-Parse-Application-Id: myAppId" -H "X-Parse-Master-Key: 123" -H "Content-Type: application/json" -d '{"where": {"did": {"$in": ["4e726747911fdfc23fb521bd3c1bc2cc"]}},"data": {"title": "The Shining","alert": "Test"}}' http://myip:1337/1/push
return message: {"result":true}
information from dashboard => push => Past Pushes:

android app can update Installation information normally. My test command: curl -X POST -H "X-Parse-Application-Id: myAppId" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' http://localhost:1337/1/classes/GameScore {"objectId":"fTJCPs1Y65","createdAt":"2016-06-27T13:18:04.361Z"}
How to debug this problem?
Even I had this problem, I just switched to onesignal.com and implemented my own logic to send notifications. It is very simple and much more efficient that parse server currently is
@faizsameerahmed96 you're more than welcome to share your improvements and help us fix those inefficiencies.
Here is how I am implementing notifications in Parse Server:
-
Open a new account on onesignal.com, for now it is 100% free!
-
Follow the steps to setup an android app (self-explanatory)
-
Setup the android app following this: https://documentation.onesignal.com/docs/android-studio-sdk-installation
-
Now use the following logic to get user's registration id..
OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() { @Override public void idsAvailable(String userId, String registrationId) { try { if (!ParseUser.getCurrentUser().getString(ParseConstants.KEY_ONE_SIGNAL_ID).equals(userId)) { ParseUser currentUser = ParseUser.getCurrentUser(); currentUser.put(ParseConstants.KEY_ONE_SIGNAL_ID, userId); currentUser.saveEventually(); Log.e("message", "Saved One Signal Player Id Successfully!"); } }catch (NullPointerException e){ e.printStackTrace(); ParseUser currentUser = ParseUser.getCurrentUser(); currentUser.put(ParseConstants.KEY_ONE_SIGNAL_ID, userId); currentUser.saveEventually(); Log.e("message", "Saved One Signal Player Id Successfully!"); } } });
Basically we are saving the registration id to the user object.
- Now you can use the dashboard provided by onesignal and the best part is that it has higher reach rates.. Also you can send notifications directly from the android app:.
eg:
OneSignal.postNotification(new JSONObject("{'contents': {'en':'" + ParseUser.getCurrentUser().getString(ParseConstants.KEY_NAME) + " wants to connect with you!'}, 'include_player_ids': ['" + user.getString(ParseConstants.KEY_ONE_SIGNAL_ID) + "']}"), null);
@faizsameerahmed96 Thinks very much for you advice, I will have a try;
My app use firebase, and parse is also used, then the devicetoken is wrong, just like this "|ID|1|:cItwhMZcO_k:APA91bHQTKYtUoh2vxMYNILKCy213gjLyAKzjz1-KgnIo6T5KwcDhhP1XDQ_YUapuBocMCG5Uf0Bn4ecgvhE4p01FUKZQVIjyh1UybWh_EQ5Oj5upe2LF1uQzdrq0bUhnmcygr78_5oV", after we remove firebase, it works.