我在Heroku中设置了解析服务器,而使用“解析云代码”推送通知不起作用?
我已经在AWS EC2实例中尝试了相同的设置,并且遇到了相同的问题。
main.js
Parse.Cloud.define('pushChannelTest', function(request, response) {
var recipientUser = request.params.user;
var message = request.params.message;
var query = new Parse.Query(Parse.Installation);
query.equalTo('username', recipientUser);
query.equalTo("deviceType", "android");
Parse.Push.send({
where: query, // for sending to a specific channel
data: message,
}, { success: function() {
console.log("#### PUSH OK");
}, error: function(error) {
console.log("#### PUSH ERROR" + error.message);
}, useMasterKey: true});
response.success('success');
});
Android代码:
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("recipientUser", editText_push.getText().toString());
params.put("message", "######");
ParseCloud.callFunctionInBackground("pushChannelTest", params, new FunctionCallback<String>() {
public void done(String success, ParseException e) {
if (e == null) {
// Push sent successfully
Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_LONG).show();
}
}
});
错误堆栈跟踪:
04-30 20:12:51.944 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Recording user engagement, ms: 42099
04-30 20:12:51.945 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Connecting to remote service
04-30 20:12:51.956 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Activity paused, time: 25125308
04-30 20:12:52.003 19652-21717/com.example.jayaprakashsivagami.water30 D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=42099, firebase_screen_class(_sc)=PushActivity, firebase_screen_id(_si)=-6471612216248973172}]
04-30 20:12:52.134 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Connection attempt already in progress
04-30 20:12:52.273 19652-21717/com.example.jayaprakashsivagami.water30 D/FA: Connected to remote service
04-30 20:12:52.275 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Processing queued up service tasks: 2
04-30 20:12:57.334 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Inactivity, disconnecting from the service
04-30 20:13:05.901 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Connecting to remote service
04-30 20:13:05.904 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Activity resumed, time: 25139280
04-30 20:13:05.952 19652-21717/com.example.jayaprakashsivagami.water30 D/FA: Connected to remote service
04-30 20:13:05.962 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Processing queued up service tasks: 1
04-30 20:13:10.968 19652-21717/com.example.jayaprakashsivagami.water30 V/FA: Inactivity, disconnecting from the service