我想知道是否有一个全面的列表,提供各种Firebase FCM使用限制的详细信息.
我知道数据消息有效负载限制最大为4KB.然后最近我的应用程序遇到了一些问题,然后认为这是由于另一个限制 - "每个设备最多4个不同的折叠键".
我还记得谷歌在最近的一次谈话中提到他们已经删除了他们以前喜欢的主题数量等限制.
我正在尝试详细了解Google对FCM使用的各种限制.
我设法通过完整的Firebase Android Codelab没有太多问题,该应用程序运行良好.现在我想添加设备到设备通知.我找到了这个教程:有些事情我不清楚.
var serviceAccount = require("path/to/serviceAccountKey.json");
什么是"ServiceAccountKey.json"文件?它只是google-services.json的另一个名称吗?如果没有,这是什么?
java google-app-engine android firebase firebase-cloud-messaging
我正在使用FCM在我的应用中提供通知.一切都运作良好,但现在我意识到,当我使用Android Studio(而非GooglePlay)安装我的应用程序时,令牌在首次运行时为空.当我关闭我的应用程序并重新启动它时,令牌不再为空.导致这个问题的原因是什么,我该如何避免呢?
InstanceIDService:
public class InstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
String token = FirebaseInstanceId.getInstance().getToken();
registerToken(token);
}
private void registerToken(String token) {
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("Token",token)
.build();
Request request = new Request.Builder()
.url("url_to_registration_script")
.post(body)
.build();
try {
client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在MainActivity中:
FirebaseMessaging.getInstance().subscribeToTopic("topic");
String token = FirebaseInstanceId.getInstance().getToken();
Log.d("TOKEN", token);
Run Code Online (Sandbox Code Playgroud)
安装并首次启动应用程序时,上次日志返回null
注册脚本:
<?php
if (isset($_POST["Token"])) {
$_uv_Token=$_POST["Token"];
$conn = mysqli_connect("localhost","user","pass","db") or die("Error connecting");
$q="INSERT INTO …Run Code Online (Sandbox Code Playgroud) 我开始使用Firebase云消息传递.
我只有指南的示例代码来使用通知和分析.如果我不安装Google Analytics通知工作正常,但当我添加gradle时,我尝试发送通知时遇到此错误:
java.lang.NoSuchMethodError:没有静态方法zzUr()Landroid/content/Intent; 在类Lcom/google/firebase/iid/FirebaseInstanceIdInternalReceiver; 或它的超类(的"com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"声明出现在/data/app/com.myapp.newapp-2/base.apk)在com.google.firebase.messaging.FirebaseMessagingService.zzz(来源不明)在com.google.firebase.iid.zzb.onStartCommand(来源不明)在android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3316)在android.app.ActivityThread.access $ 2200(ActivityThread.java:177)在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1547)在android.os.Handler.dispatchMessage(Handler.java:102)在android.os.Looper.loop(Looper.java:145)的机器人. app.ActivityThread.main(ActivityThread.java:5951)在java.lang.reflect.Method.invoke(本机方法)在java.lang.reflect.Method.invoke(Method.java:372)在com.android.internal. os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
我在gradle中:
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.firebase:firebase-core:9.2.0'
Run Code Online (Sandbox Code Playgroud)
我的MyFirebaseMessagingService:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
Log.d(TAG, "From: …Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-analytics
我正在Android中实施FCM通知,但通知如何根据应用状态(背景与前景)而有所不同?

我使用带有Postman的FCM API发送通知,这是通知结构:
{ "notification": {
"title": "Notification title",
"body": "Notification message",
"sound": "default",
"color": "#53c4bc",
"click_action": "MY_BOOK",
"icon": "ic_launcher"
},
"data": {
"main_picture": "URL_OF_THE_IMAGE"
},
"to" : "USER_FCM_TOKEN"
}
Run Code Online (Sandbox Code Playgroud)
要渲染的图像取自data.main_picture.
我实现了自己的功能FirebaseMessagingService,使通知在前景状态下完美显示.通知代码是下一个:
NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
notiStyle.setSummaryText(messageBody);
notiStyle.bigPicture(picture);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(bigIcon)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setStyle(notiStyle); code here
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
Run Code Online (Sandbox Code Playgroud)
但是,在后台,甚至没有执行该服务.在AndroidManifest.xml,Firebase服务声明如下:
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service …Run Code Online (Sandbox Code Playgroud) android background push-notification firebase-cloud-messaging
我正在使用firebase控制台,并且只能使用它发送通知消息.
有没有办法使用相同的方式发送数据消息?
我是Firebase的新手,当我的Java应用程序尝试使用客户端的Firebase令牌发送通知/消息时,我遇到错误,例如错误的发件人ID和HTTP状态401的身份验证错误.请注意,使用Firebase控制台,我可以将消息发送到客户端.
对于客户端应用程序,我执行了以下操作:
messaging快速入门应用程序来自这里 - https://github.com/firebase/quickstart-android/tree/master/messaging - 已经设置了Firebase依赖等.加载克隆的应用程序Android Studio.My Notification Client并使用com.google.firebase.quickstart.fcmAndroid应用程序的软件包名称添加了一个应用程序.google-services.json的Android应用程序文件已添加到新创建的项目中,并将其复制到该messaging/app/文件夹并与内部的成绩文件同步Android Studio.Android Studio.当应用程序加载到模拟器中时,单击该Log Token按钮以在Android Monitor选项卡中捕获客户端的Firebase令牌Android Studio.My Notification Client,单击Notifications左窗格中的链接,并通过粘贴上一步中捕获的Firebase令牌向设备发送通知.这很棒!下一步是使用单独的简单Java应用程序(最终将成为通知服务器)将通知发送到客户端而不是使用Firebase控制台.
为此,我按照此处列出的步骤进行了操作 - https://firebase.google.com/docs/server/setup#prerequisites.具体来说,这些是我执行的步骤:
My Notification ServerFirebase Console 的新项目.Settings > Permissions在Firebase控制台中使用,创建了一个新的服务帐户并下载了该serviceAccountCredentials.json文件. <dependency>
<groupId>com.google.gcm</groupId>
<artifactId>gcm-server</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-server-sdk</artifactId>
<version>3.0.0</version> …Run Code Online (Sandbox Code Playgroud) 我正在使用 Firebase Cloud Messaging 实现推送通知,为此我在我的 AndroidManifest.xml 文件中添加了此代码
<!--FCM RECEIVER-->
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false"/>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
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="${applicationId}"/>
</intent-filter>
</receiver>
<!---FCM RECEIVER ENDS HERE-->
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行该应用程序时,它甚至在开始活动之前就抛出了该应用程序
Java.Lang.NoClassDefFoundError: 'Failed resolution of: Lcom/google/android/datatransport/runtime/dagger/internal/Factory;'
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我为此功能安装了两个 NuGet 包:
我试过了:
c# java android-manifest xamarin.android firebase-cloud-messaging
我在Android中使用Firebase云消息传递(FCM)API进行推送通知.当我实施那个时间完美的工作,但现在它找不到谷歌播放的服务.
错误是:
FirebaseInstanceId:后台同步失败:SERVICE_NOT_AVAILABLE,
请帮我解决一下.我在gradle文件中使用了以下依赖项.
dependencies {
compile files('libs/ksoap2-android-assembly-3.4.0-jar.jar')
compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/gson-2.2.4.jar')
compile files('libs/activation.jar')
compile files('libs/mail.jar')
compile files('libs/additionnal.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.14.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile('com.google.android.gms:play-services:9.0.2') {
exclude group: "play-services-wallet"
exclude module: "play-services-wallet"
exclude group: "play-services-ads"
exclude module: "play-services-ads"
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您抽时间阅读.