Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php发送推送后解析接收器android代码_Php_Push Notification_Push_Android Notifications_Parse Android Sdk - Fatal编程技术网

从php发送推送后解析接收器android代码

从php发送推送后解析接收器android代码,php,push-notification,push,android-notifications,parse-android-sdk,Php,Push Notification,Push,Android Notifications,Parse Android Sdk,我有一个PHP代码来发送推送通知,PHP脚本返回`{“result”:true},但它没有显示在设备上。我想我需要写一个自定义的接收器代码。我的接收器类别为: package com.phpand; import org.json.JSONException; import org.json.JSONObject; import android.content.BroadcastReceiver; import android.content.Context; import android.

我有一个PHP代码来发送推送通知,PHP脚本返回`{“result”:true},但它没有显示在设备上。我想我需要写一个自定义的接收器代码。我的接收器类别为:

package com.phpand;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class ParseReceiver extends BroadcastReceiver {

private static final String TAG = ParseReceiver.class.getName();

@Override
public void onReceive(Context context, Intent intent) {

    Bundle extras = intent.getExtras();
    String message = extras != null ? extras
            .getString("customdata") : "";
    JSONObject jObject;
    try {
        jObject = new JSONObject(message);
        Log.d(TAG,
                jObject.getString("alert")
                        + jObject.getString("action"));
    } catch (JSONException e1) {
        e1.printStackTrace();
    }

}
}
舱单内容如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.phpand"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name=".permission.RECEIVE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="com.phpand.permission.C2D_MESSAGE" />

    <permission
        android:name="com.phpand.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name="com.phpand.ParseMainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>


     </activity>
   <service android:name="com.parse.PushService" />

        <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>
        <receiver
            android:name="com.phpand.ParseReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.OPEN" />
                <action android:name="com.parse.push.intent.DELETE" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.MyStuff.stuff" />
            </intent-filter>
        </receiver>
        </application>

    </manifest>

谁能帮我摆脱这一切。
注意:所有推送消息都显示在parse.com的仪表板上

我想这是onReceive中的前两行,保存的目的在哪里。如果您使用parse发送通知,那么您必须实现自定义接收器,该接收器实现了
ParsePushBroadcastReceiver
@ved~也尝试了同样的方法,但是无法接收.GCM或解析推送??我使用的是Parse Push我想这是onReceive中的前两行,保存意图的位置。如果您使用Parse发送通知,那么您必须实现自定义接收器,该接收器实现了
ParsePushBroadcastReceiver
@ved~也尝试了同样的方法,但无法接收.GCM或解析推送??我正在使用解析推送