Android,使用parse.com推送通知,自动启动应用程序

Android,使用parse.com推送通知,自动启动应用程序,第1张

概述我的问题是,当推送来自解析服务时,有时应用程序会自动打开,就好像我点击通知栏中的通知一样. 也许某人已经遇到过类似的问题? 这是我的CustomReseiver: public class CustomPushReceiver extends ParsePushBroadcastReceiver {private final String TAG = CustomPushReceiver.cla 我的问题是,当推送来自解析服务时,有时应用程序会自动打开,就好像我点击通知栏中的通知一样.
也许某人已经遇到过类似的问题?

这是我的Customreseiver:

public class CustompushReceiver extends ParsePushbroadcastReceiver {private final String TAG = CustompushReceiver.class.getSimplename();private Intent parseIntent;public CustompushReceiver() {    super();}@OverrIDeprotected voID onPushReceive(Context context,Intent intent) {    super.onPushReceive(context,intent);    if (intent == null)        return;    try {        JsONObject Json = new JsONObject(intent.getExtras().getString("com.parse.Data"));        Log.e(Constans.LOG_TAG,"Push received: " + Json);        parseIntent = intent;        // Toast.makeText(ParseApplication.get(),Json.getString("alert"),Toast.LENGTH_SHORT).show();        if(ProfileBrIEfsFragment.profileBrIEfsContext instanceof Profile_SIDebar_Activity){            ((Profile_SIDebar_Activity)ProfileBrIEfsFragment.profileBrIEfsContext).pushReceived(Json);        }        CurrentUser.getInstance().setHaveNewNotIDication(true);        Notification_center_Activity.updateNotifications();    } catch (JsONException e) {        Log.e(TAG,"Push message Json exception: " + e.getMessage());    }}@OverrIDeprotected voID onPushdismiss(Context context,Intent intent) {    super.onPushdismiss(context,intent);}@OverrIDepublic voID onPushOpen(Context context,Intent intent) {    Intent i = new Intent(context,NewHomeActivity.class);    i.putExtras(intent.getExtras());    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);    context.startActivity(i);}public interface OnPushReceived{    voID pushReceived(JsONObject Json);}}
解决方法 试试这个

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {           // Initialize Parse           Parse.initialize(this,"your ID from parse");           ParseInstallation.getCurrentInstallation().saveInBackground();           Parse.setLogLevel(Parse.LOG_LEVEL_INFO);       }  PushService.setDefaultPushCallback(this,MainActivity.class,R.drawable.ic_notification);

只有当您单击通知MainActivity Opened时才使用setDefaultPushCallback.

希望有用.

@H_502_35@ 总结

以上是内存溢出为你收集整理的Android,使用parse.com推送通知,自动启动应用程序全部内容,希望文章能够帮你解决Android,使用parse.com推送通知,自动启动应用程序所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1125588.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存