Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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
Android Firebase推送通知为空(无文本)_Android_Firebase_Notifications_Push_Firebase Cloud Messaging - Fatal编程技术网

Android Firebase推送通知为空(无文本)

Android Firebase推送通知为空(无文本),android,firebase,notifications,push,firebase-cloud-messaging,Android,Firebase,Notifications,Push,Firebase Cloud Messaging,我的android应用推送通知有问题。 我的推送通知为空,仅显示应用程序名称。消息字段为空 Androidmanifest.xml MyAppWebViewClient.java 布局-->活动\u main.xml 值->pushbots.xml XXXXXXXX MyPushBotsKey XXXXXXXXX Mysenderid 调试 值->字符串.xml 我的应用程序名称 我的替代标签 设置 更改 <service android:name="com.pushbots

我的android应用推送通知有问题。 我的推送通知为空,仅显示应用程序名称。消息字段为空

Androidmanifest.xml MyAppWebViewClient.java 布局-->活动\u main.xml

值->pushbots.xml

XXXXXXXX MyPushBotsKey
XXXXXXXXX Mysenderid
调试
值->字符串.xml

我的应用程序名称
我的替代标签
设置
更改

 <service android:name="com.pushbots.push.GCMIntentService" />
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>



请发布您的GCMBroadcastReceiver类

您能告诉我如何添加GCMBroadcastReceiver类吗?在中,添加哪个文件?由于我还是初学者,您应该尝试使用Firebase云消息传递。它可以包含更多的功能,并且比GCM容易得多。正如您所看到的,我已经使用Firebase云消息来实现清单,但我不知道如何将GCMBroadcast receiver类实现到MainActivity.java。因为我有php开发人员,还在学习android,所以请在我上面的代码中实现Firebase云消息。不要实现这个类。不需要接收器。它们是自动添加的。创建2个服务-令牌服务扩展FirebaseInsatnceIDService。以及扩展Firebase消息服务的通知服务。在令牌服务中覆盖ontokenrefresh()方法,在通知服务中覆盖接收到的消息()
package in.myappname.apk;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.pushbots.push.Pushbots;

public class MainActivity extends Activity {

    private WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Pushbots.sharedInstance().init(this);

        mWebView = (WebView) findViewById(R.id.activity_main_webview);

        // Force links and redirects to open in the WebView instead of in a browser
        mWebView.setWebViewClient(new WebViewClient());

        // Enable Javascript
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        // Use remote resource
        mWebView.loadUrl("http://myappurl.in");

        // Stop local links and redirects from opening in browser instead of WebView
        mWebView.setWebViewClient(new MyAppWebViewClient());

        // Use local resource
        // mWebView.loadUrl("file:///android_asset/www/index.html");
    }

    // Prevent the back-button from closing the app
    @Override
    public void onBackPressed() {
        if(mWebView.canGoBack()) {
            mWebView.goBack();
        } else {
            new AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle("Alert")
                    .setMessage("Are you sure you want exit?")
                    .setPositiveButton("Yes", new DialogInterface.OnClickListener()
                    {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();
                        }

                    })
                    .setNegativeButton("No", null)
                    .show();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
package in.myappnam.apk;

import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MyAppWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (Uri.parse(url).getHost().endsWith("myappname.in")) {
            return false;
        }

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        view.getContext().startActivity(intent);
        return true;
    }
}
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="in.myappname.apk.MainActivity">

        <WebView
            android:id="@+id/activity_main_webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>
 <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- Pushbots Application ID  -->
        <string name="pb_appid">xxxxxxxxxMypushbotskey</string>
        <!-- Project Number in Google console -->
        <string name="pb_senderid">xxxxxxxxxxMysenderid</string>
        <!-- Pushbots Log Level  log Tag "PB2" -->
        <string name="pb_logLevel">DEBUG</string>
    </resources>
 <?xml version="1.0" encoding="utf-8"?>
    <resources>

        <string name="app_name">My App Name</string>
        <string name="hello_world">My Alternative tag</string>
        <string name="action_settings">Settings</string>

    </resources>
 <service android:name="com.pushbots.push.GCMIntentService" />
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
<service android:name="com.pushbots.push.GCMIntentService" >
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
 </service>