我已经创建了一个 Azure 通知中心命名空间,我尝试通过输入 API 密钥来配置它的 Google FCM 部分,但是当我这样做时,它给了我这个错误
更新通知中心时出错 {"error":{"code":"BadRequest","message":"Firebase 凭据无效。"}}
我从 google-services.json 文件中添加的密钥
但是,当我从 FCM 控制台发送通知时,我可以发送并接收通知。
任何意见将不胜感激
xamarin.android azure-notificationhub xamarin.forms firebase-cloud-messaging
我可以使用下面的 CURL 请求使用 Firebase Messaging 发送通知。我当前正在使用 OAuth 2.0 Playground 来获取访问令牌。我需要实现一个 PHP 脚本来执行此操作。如何在 PHP 中以编程方式生成访问令牌?
curl -X POST -k -H 'Authorization: Bearer access_token_goes_here' -H 'Content-Type: application/json' -i 'https://fcm.googleapis.com/v1/projects/projectId/messages:send' --data '{
"message":{
"topic" : "newTopic",
"notification" : {
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message"
}
}
}
Run Code Online (Sandbox Code Playgroud) 我无法一次发送多条消息。我已浏览 FCM 文档,但没有找到任何端点。
https://firebase.google.com/docs/cloud-messaging/send-message#send-a-batch-of-messages
headers = [
{"Authorization", "Bearer #{access_token}"},
{"Content-Type", "application/json"}
]
response =
HTTPoison.post!(
"https://fcm.googleapis.com/v1/projects/digimep-f4db3/messages:send",
Jason.encode!(payload),
headers
)
Run Code Online (Sandbox Code Playgroud)
如果你们对此有任何想法,请告诉我。
我已在我的应用程序中实施了FCM Firebase云消息传递.当应用程序处于forground模式时,我收到通知及其数据.
问题:
当我的应用程序处于后台模式或当时被杀死时,通知会通过FCM自动生成.所以我无法控制到达的通知数据(通知的coustom数据字段).当应用程序处于后台模式并且通知到达时,MyFirebaseMessagingService类的onMessageReceived(RemoteMessage remoteMessage)方法不会调用.
请帮助在两种模式下获得通知控制(与GCM相同)
在我的谷歌搜索中,我们只能从FCM控制台向所有用户发送通知.目前REST API中不支持此功能.
但是我们可以在REST API中指定一个主题,并且订阅该主题的任何人都将获得通知.
对单个主题的用户数有任何限制.如果10k用户订阅该主题并且REST API选择该主题来发送通知,该怎么办?FCM会向所有10k用户发送通知吗?
我问这个是因为当我尝试按主题从控制台发送通知时,它显示"<1000估计用户".见下面的截图.
我正在尝试设置Android手机从服务器接收通知的系统:对于此任务,我们选择了Firebase.虽然应用程序在后台运行,但一切正常:在我从firebase控制台推送消息后,系统托盘上会显示一条消息,并且在用户单击消息后,Intent会向其发送一条额外的数据Activity.
当应用程序已经处于前台时,我的问题是唯一的.该火力点通知是相当清楚的:如果应用程序是在前台,无论哪个类型的邮件服务器发送,OnMessageReceived不会被调用 ...那么,为什么它不能与我的简单的应用程序?一些注意事项可以帮助您解决此问题:
您可以在下面找到所有使用的源代码:
主要活动
package it.bagozi.ada.tutorial.firebase;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private TextView notification;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.notification = (TextView) this.findViewById(R.id.notification_setter);
Intent i = this.getIntent();
Log.e(TAG, "Intent from Activity caller: " + i);
if (getIntent().getExtras() != null) {
for (String key : getIntent().getExtras().keySet()) …Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-notifications
我这样实现:
public static void setPushSetting(Context context, boolean flag) {
if(flag) {
FirebaseInstanceId.getInstance().getToken();
} else {
try {
FirebaseInstanceId.getInstance().deleteInstanceId();
} catch (IOException e) {
RxBus.getInstance().post(new OffPushError());
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
昨天,它有效,但今天FirebaseInstanceId.getInstance().deleteInstanceId();总是抛出异常.
在禁用和启用Firebase推送通知时是否还有其他方法可以实施?谢谢你的帮助!
-------更新异常的日志-------------
java.io.IOException: MAIN_THREAD
at com.google.firebase.iid.zzd.zzb(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.deleteInstanceId(Unknown Source)
at jp.seesaa.itmama.push.PushUtil.setPushSetting(PushUtil.java:32)
at jp.seesaa.itmama.ui.main.setting.SettingFragment.onSharedPreferenceChanged(SettingFragment.java:66)
at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:476)
at android.app.SharedPreferencesImpl$EditorImpl.apply(SharedPreferencesImpl.java:384)
at android.support.v4.content.EditorCompatGingerbread.apply(EditorCompatGingerbread.java:25)
at android.support.v4.content.SharedPreferencesCompat$EditorCompat$EditorHelperApi9Impl.apply(SharedPreferencesCompat.java:45)
at android.support.v4.content.SharedPreferencesCompat$EditorCompat.apply(SharedPreferencesCompat.java:67)
at android.support.v7.preference.Preference.tryCommit(Preference.java:1353)
at android.support.v7.preference.Preference.persistBoolean(Preference.java:1558)
at android.support.v7.preference.TwoStatePreference.setChecked(TwoStatePreference.java:79)
at android.support.v7.preference.TwoStatePreference.onClick(TwoStatePreference.java:64)
at android.support.v7.preference.Preference.performClick(Preference.java:971)
at android.support.v7.preference.Preference.performClick(Preference.java:957)
at android.support.v7.preference.SwitchPreferenceCompat.performClick(SwitchPreferenceCompat.java:203)
at android.support.v7.preference.Preference$1.onClick(Preference.java:145)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95) …Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-notifications
我正在为一个版本集成Firebase消息:
'com.google.firebase:firebase-messaging:15.0.2'
Run Code Online (Sandbox Code Playgroud)
我的类路径是: -
classpath 'com.google.gms:google-services:3.2.0'
Run Code Online (Sandbox Code Playgroud)
我有Faced跟随错误: -
无法解决:firebase-messaging打开文件
android firebase google-play-services android-studio firebase-cloud-messaging
我正在尝试测试将Firebase用于使用邮递员的推送通知的应用程序。
我正在专门测试Http v1 Api,并寻找如何授权请求。
我需要做的就是让OAuth2令牌在Postman中使用,尽管我不确定如何使用,但我应该可以在OAuth 2.0操场上使用它。
我有privatkey.json从firebase控制台下载的文件,我只需要知道如何使用它来获取将添加为POST请求的承载授权标头的令牌