簡體   English   中英

無法收到解析的Android Push通知

[英]Parse Android Push notification fails to be received

我一直在嘗試通過Parse獲取通知,根據它發送通知的頁面,但是模擬器什么也沒得到。 請幫忙 :(

我的課

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.PushService;


public class FARQ_UANL extends ActionBarActivity {

private int cont=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_farq__uanl);

    //Parse
    Parse.initialize(this, "key", "key");
    PushService.setDefaultPushCallback(this, FARQ_UANL.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();

    final WebView myWebView = (WebView) this.findViewById(R.id.pagweb);
    myWebView.loadUrl("http://www.arquitectura.uanl.mx/");

    Button btn1 = (Button) findViewById(R.id.home);
    Button btn2 = (Button) findViewById(R.id.calendario);
    Button btn3 = (Button) findViewById(R.id.buzon);
    Button btn4 = (Button) findViewById(R.id.mapa);
    Button btn5 = (Button) findViewById(R.id.directorio);
    Button btn6 = (Button) findViewById(R.id.faq);

    btn1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://www.arquitectura.uanl.mx/");
            cont++;
            if(cont==6) {
                //toast
                Toast tostito =
                        Toast.makeText(getApplicationContext(),
                                "Bienvenido al infierno", Toast.LENGTH_SHORT);
                tostito.show();
            }

        }
    });

    btn2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://www.arquitectura.uanl.mx/calendario.html");
            cont=0;
        }
    });

    btn3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://arquitectura.uanl.mx/buzondesugerencias.html");
            cont=0;
        }
    });

    btn4.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://arquitectura.uanl.mx/instalaciones.html");
            cont=0;
        }
    });

    btn5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://arquitectura.uanl.mx/directorio.html");
            cont=0;
        }
    });

    btn6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myWebView.loadUrl("http://arquitectura.uanl.mx/informacion.html#faq");
            cont=0;
        }
    });
  }
}

Android清單

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


<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<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="karudia.com.farq.permission.C2D_MESSAGE" />
<uses-permission android:name="karudia.com.farq.permission.C2D_MESSAGE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/iniciales"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".FARQ_UANL"
        android:label="@string/iniciales" >
        <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.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>
    <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="karudia.com.farq" />
        </intent-filter>

    </receiver>

</application>

如果有人知道使用推送通知的其他方法,請告訴我

這一部分您放置了Application類的onCreate方法

//Parse
Parse.initialize(this, "key", "key");
PushService.setDefaultPushCallback(this, FARQ_UANL.class);
ParseInstallation.getCurrentInstallation().saveInBackground();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM