【问题标题】:Parse.com push notification when phone locked(android)手机锁定时 Parse.com 推送通知(android)
【发布时间】:2015-09-17 11:09:45
【问题描述】:

对不起我的英语。你能告诉我我怎么能喜欢这样:我已经锁定了手机,如果在手机锁定其节目时推送通知(就像你接到电话一样)。我使用 Parse.com

这是我的设置:

 // Initialize Crash Reporting.
    ParseCrashReporting.enable(this);

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    // Add your initialization code here
    Parse.initialize(this, "-", "-");

    //ParseInstallation.getCurrentInstallation().saveInBackground();

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    // Optionally enable public read access.
    // defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true); 

清单

 <receiver android:name="----Receiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.DELETE" />
                <action android:name="com.parse.push.intent.OPEN" />
            </intent-filter>
        </receiver>

接收者

 @Override
    public void onPushOpen(Context context, Intent intent) {
        ParseAnalytics.trackAppOpenedInBackground(intent);
        //String uriString = null;

        try {

            Bundle extras = intent.getExtras();

            if (extras != null) {
                String jsonData = extras.getString("com.parse.Data");
                JSONObject json;

                Log.e("json", json.toString());

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }


    }

【问题讨论】:

    标签: android parse-platform push


    【解决方案1】:

    创建一个扩展 ApplicationParseApplication 类,并在该类中初始化 Parse sdk 并将其从您的活动中删除。

    然后,作为AndroidManifest.xml 上application 属性的这一行:

    android:name=".ParseApplication"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多