Android解析sdk推送通知
Android parse sdk推送通知正在emulator上运行,但当我使用usb调试在手机上运行它时,推送通知会在后端触发,可以在parse.com帐户中看到,但手机没有收到推送通知Android解析sdk推送通知,android,push-notification,parse-platform,Android,Push Notification,Parse Platform,Android parse sdk推送通知正在emulator上运行,但当我使用usb调试在手机上运行它时,推送通知会在后端触发,可以在parse.com帐户中看到,但手机没有收到推送通知 public class Profile_InviteActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(saved
public class Profile_InviteActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile__invite);
Bundle extras = getIntent().getExtras();
ParseQuery<ParseObject> query = ParseQuery.getQuery("UserProfile");
Log.d("id",""+extras.getInt("fid"));
query.whereEqualTo("fid", ""+extras.getInt("fid"));
query.findInBackground(new FindCallback<ParseObject>() {
public void done(final List<ParseObject> scoreList, ParseException e) {
if (e == null) {
TextView name = (TextView) findViewById(R.id.profile_name);
TextView location = (TextView) findViewById(R.id.profile_location);
name.setText(scoreList.get(0).getString("name"));
location.setText(scoreList.get(0).getString("location"));
ParseFile img1 = (ParseFile)scoreList.get(0).get("profileimage");
img1.getDataInBackground(new GetDataCallback() {
public void done(byte[] data,
ParseException e) {
if (e == null) {
Log.d("test",
"We've got data in data.");
// Decode the Byte[] into
// Bitmap
ImageView image = (ImageView) findViewById(R.id.profimg);
image.setImageBitmap(BitmapFactory
.decodeByteArray(
data, 0,
data.length));
} else {
Log.d("test",
"There was a problem downloading the data.");
}
}
});
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
}
public void inviteToTrain(View v)
{
Log.d("inviting","now");
Bundle extras = getIntent().getExtras();
//ParseInstallation installation = ParseInstallation.getCurrentInstallation();
//installation.put("fids",true);
//installation.saveInBackground();
ParseQuery pushQuery = ParseInstallation.getQuery();
//pushQuery.whereEqualTo("fid", extras.getInt("fid"));
pushQuery.whereEqualTo("fids", true);
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
push.setMessage("Someone would like to join you at your event ");
push.sendInBackground();
Log.d("invited","now");
}
public class Profile\u InviteActivity扩展活动{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u profile\u invite);
Bundle extras=getIntent().getExtras();
ParseQuery=ParseQuery.getQuery(“UserProfile”);
Log.d(“id”和“+extras.getInt”(“fid”);
查询:whereEqualTo(“fid”)、“+extras.getInt(“fid”);
findInBackground(新的FindCallback(){
公共作废完成(最终列表得分列表,e){
如果(e==null){
TextView name=(TextView)findViewById(R.id.profile\u name);
TextView位置=(TextView)findViewById(R.id.profile\u位置);
name.setText(scoreList.get(0.getString(“name”));
location.setText(scoreList.get(0.getString)(“location”);
ParseFile img1=(ParseFile)scoreList.get(0.get(“profileimage”);
img1.getDataInBackground(新的GetDataCallback(){
公共作废完成(字节[]数据,
解析异常(e){
如果(e==null){
Log.d(“测试”,
“数据中有数据。”);
//将字节[]解码为
//位图
ImageView图像=(ImageView)findViewById(R.id.profimg);
image.setImageBitmap(位图工厂
.decodeByteArray(
数据,0,
数据长度);
}否则{
Log.d(“测试”,
“下载数据时出现问题。”);
}
}
});
}否则{
Log.d(“分数”,“错误:+e.getMessage());
}
}
});
}
公共培训(视图五)
{
日志d(“邀请”、“现在”);
Bundle extras=getIntent().getExtras();
//ParseInstallation=ParseInstallation.getCurrentInstallation();
//安装。放置(“fids”,正确);
//安装。saveInBackground();
ParseQuery pushQuery=ParseInstallation.getQuery();
//pushQuery.whereEqualTo(“fid”),extras.getInt(“fid”);
pushQuery.whereEqualTo(“fids”,真);
//向查询发送推送通知
ParsePush push=新的ParsePush();
setQuery(pushQuery);//设置我们的安装查询
setMessage(“有人想加入您的活动”);
推送。发送背景();
日志d(“已邀请”、“现在”);
}
}
请帮我做这个
谢谢为了获得推送通知 你必须编写广播接收器来处理这个问题 示例代码: 初始化解析详细信息后,添加以下内容
PushService.setDefaultPushCallback(this, SampleClass.class);
然后在你的清单文件中,添加这个
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
更多详细信息,请参阅
谢谢,但我已经这样做了。只有每次创建这样的新对象时,我才会在手机上收到推送通知。它不适用于旧的注册对象。ParseInstallation=ParseInstallation.getCurrentInstallation();安装。放置(“fids”,正确);安装。saveInBackground();
{ "alert": "Notification", "title": "Push", "objectId": "objectId",
"objectType": "type", "action": "Your Action Name" }