使用parse.com推送通知未在设备上收到

时间:2015-05-20 11:26:18

标签: android parse-platform push-notification device

这是我在android中使用parse.com发送推送通知的代码。

ParseQuery installQuery = ParseInstallation.getQuery();
					installQuery.whereEqualTo("userId",  recieverObjectID);
					



ParsePush androidPush = new ParsePush();
					    androidPush.setMessage(currentUser.getUsername());
					    androidPush.setQuery(installQuery);
					    androidPush.sendInBackground();

在模拟器中,我能够发送和接收推送通知,但我无法在设备上接收推送通知。当push-type为gcm时,我设法在安装解析表中检索这些设备或模拟器不发送推送通知。指导我解决方案。

4 个答案:

答案 0 :(得分:0)

if you are having a Parse account please go through the docs provided over there that will help you alot. you will have to make a class of parse application
public class ParseApplication  extends Application{



   public void onCreate() {
        super.onCreate();

          Parse.initialize(this,"app_id","Client_id");



        ParseUser.enableAutomaticUser();




        }

}

 then in your launcher activity you have to intialise parse like this:

 ParseInstallation currentInstall=ParseInstallation.getCurrentInstallation();

答案 1 :(得分:0)

您是否按照文档中的说明制作了Parse Installation表。你必须在Parse上注册你的设备。

答案 2 :(得分:0)

首先这样做:           ParsePush androidPush = new ParsePush();                         androidPush.setMessage(currentUser.getUsername());                         androidPush.setQuery(installQuery);                         androidPush.saveInBackground(); 检查你的清单然后你是缺少一些权限可以是互联网许可或下面给出:                                                         然后在应用程序标签中:        

   <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.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="YOUR PACKAGE NAME" />
   </intent-filter>
    </receiver>
      <receiver android:name="com.parse.ParsePushBroadcastReceiver"           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>

答案 3 :(得分:-2)

行。那么在你的解析账户中点击推送你肯定会有所推动。