简体   繁体   English

在信息中心中解析发送通知,但Android设备未接收到

[英]Parse sending notifications in dashboard but Android device not receiving

I've successfully created a Parse app and I'm using the application keys in my Android app implementation. 我已经成功创建了一个Parse应用程序,并且在我的Android应用程序实现中使用了应用程序密钥。 I've followed all the steps here https://www.parse.com/apps/quickstart?onboard=#parse_push/android/existing (registration required unfortunately, but it's an instant process) and when I send a test push notification it is dispatched from the dashboard and is even received by a virtual device I'd set up as a control but nothing happens on a physical device. 我已按照这里的所有步骤进行操作https://www.parse.com/apps/quickstart?onboard=#parse_push/android/existing (很遗憾,需要注册,但这是一个即时过程) ,当我发送测试推送通知时,从仪表板调度,甚至被我设置为控件的虚拟设备接收,但物理设备上没有任何反应。 I thought it might be a socket issue so I alternated between wifi and 3G connections with no success 我以为可能是套接字问题,所以我在wifi和3G连接之间进行了交替,但没有成功

Here's the code I'm using: 这是我正在使用的代码:

Main: 主要:

package com.wetu.chronicle;

import android.os.Bundle;
import org.apache.cordova.*;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.PushService;

public class chronicle extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    super.loadUrl(Config.getStartUrl());        
    Parse.initialize(this, "xxxxxxxxx",     "yyyyyyyyyyyy");
    PushService.setDefaultPushCallback(this, chronicle.class);
    PushService.subscribe(this, "Newsfeed", chronicle.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();
}
}

Android Manifest: Android清单:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission     android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!--
      IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
      to match your app's package name + ".permission.C2D_MESSAGE".
    -->
    <permission android:protectionLevel="signature"
        android:name="com.wetu.chronicle.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.wetu.chronicle.permission.C2D_MESSAGE" />
<application
        android:debuggable="false"
        android:hardwareAccelerated="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name" tools:ignore="HardcodedDebugMode">

        <activity android:name="chronicle" android:label="@string/app_name"
                android:theme="@android:style/Theme.Black.NoTitleBar"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
            <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.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" />

            <!--
              IMPORTANT: Change "com.parse.starter" to match your app's package name.
            -->
            <category android:name="com.wetu.chronicle" />
          </intent-filter>
        </receiver>
    </application>

    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19"/>

I'm available to clarify any questions you might have and/or post additional code. 我可以澄清您可能遇到的任何问题和/或发布其他代码。

Its most likely because your app isn't active in the background. 最有可能的原因是您的应用在后台未处于活动状态。 A lot of my android apps have been struggling from this. 我的许多Android应用程序都在为此苦苦挣扎。 A decent solution might be to make sure there is an alarm clock that wakes the app up. 体面的解决方案可能是确保有一个闹钟将应用程序唤醒。 I've never dealt with parse though so this may not work, its worked for me in other scenarios though 我从来没有处理过解析,所以这可能行不通,尽管它在其他情况下对我也有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM