我正在尝试触发我的 Android 应用程序来接收简单的推送消息。我想用cURL. 我尝试遵循文档 ,但收到 401...这曾经有效,有什么变化吗?
我使用以下代码检索了我的设备令牌:
FirebaseMessaging.getInstance().token.addOnSuccessListener { token: String ->
if (!TextUtils.isEmpty(token)) {
Log.d("TAG", "retrieve token successful : $token")
} else {
Log.w("TAG", "token should not be null...")
}
}.addOnFailureListener { e: Exception? -> }.addOnCanceledListener {}
.addOnCompleteListener { task: Task<String> ->
Log.v("TAG", "This is the token : " + task.result)
}
Run Code Online (Sandbox Code Playgroud)
我的卷曲代码:
curl -X POST -H "Authorization: Bearer AAAArxt...CelsCl" -H "Content-Type: application/json" -d '{
"message":{
"notification":{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的android项目中集成Urban Airship Push通知服务.我在谷歌开发者控制台中创建了一个新项目,并创建了一个GCM服务器密钥.我在Urban Airship配置中添加了GCM密钥,但它无法发送通知.
Urban Airship Error Console会抛出错误
Received push with invalid authorization on platform GCM error message
Run Code Online (Sandbox Code Playgroud)
我已经在2个月前在Google开发者控制台中创建了一个测试项目,并且拥有有效的GCM密钥.如果我将此密钥集成到UA中,它可以正常工作.但是,如果我在同一个项目中创建一个不起作用的新服务器密钥.
最近创建了API密钥4,但它在6月9日创建的服务器密钥工作正常.这是因为密钥是自动生成的吗?如果这是问题,我该如何自动创建GCM服务器密钥?
最近,我听说GCM正在迁移到Firebase.我是否需要使用FCM密钥而不是GCM?
android urbanairship.com google-cloud-messaging firebase-cloud-messaging
我正在将FCM整合到我的项目中.但收到通知后,我在Log中遇到错误.(错误文字颜色为蓝色)
W/FirebaseMessaging: Received message with unknown type: text
Run Code Online (Sandbox Code Playgroud)
我的代码是这样的:
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("Notification", "Success");
sendNotification(remoteMessage);
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,第一行没有执行,也没有调试.
测试我的服务器端php函数以创建设备组时,notification key由于成功创建了设备组,因此我无法跟踪返回的信息。
如我尝试过的https://groups.google.com/forum/#!topic/firebase-talk/ytovugx8XNs中所述
curl -v -H Content-Type:application/json -H Authorization:key=<your api key>
-H project_id:<your project id>
https://android.googleapis.com/gcm/notification?notification_key_name=testgroup
Run Code Online (Sandbox Code Playgroud)
其中项目ID是在Firebase控制台中找到的项目ID,URL中显示的项目ID和即使在我 google-services.json
结果我得到了
HTTP / 1.1 400错误的请求内容类型:application / json; charset = UTF-8日期:2017年4月18日星期二08:21:30 GMT过期:2017年4月18日星期二08:21:30 GMT缓存控制:私有,最大年龄= 0 X内容类型选项: nosniff X-Frame-Options:SAMEORIGIN X-XSS-Protection:1;mode = block服务器:GSE Alt-Svc:quic =“:443”; ma = 2592000; v =“ 37,36,35”接受范围:无更改:接受编码传输编码:分块
* Curl_http_done:称为过早== 0 *主机android.googleapis.com的连接#0完好无损{“错误”: “ INVALID_PROJECT_ID”}
我找不到解决办法,因为丢失通知密钥后,唯一的恢复方法是使用该命令(afaik)。请帮忙。
我正在尝试使用Firebase进行推送通知.但是,我已经遇到了障碍,即我无法在iOS中做那件事.我尝试了两种方法
Messaging.messaging().setAPNSToken(deviceToken, type: .prod) and InstanceID.instanceID().setAPNSToken(deviceToken, type: InstanceIDAPNSTokenType.sandbox)
Run Code Online (Sandbox Code Playgroud)
在第二
application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
Run Code Online (Sandbox Code Playgroud)
与Firebase进口.
我该怎么办?
编辑:这是一个补充信息,错误信息是这样的. 无法获取默认令牌Error Domain = com.firebase.iid Code = 1003"(null)" 我用Google搜索,但没有相关信息.
我正在开发一个使用CallKit通知用户的应用程序.但是,我正在使用APN测试应用程序,但它无法正常工作.
流程应为:接收FCM - >使用Callkit创建呼叫 - >用户接受呼叫 - >执行某些操作.
流程类似于应用程序类似于什么,但我没有VOIP,我只需要确保CALLKIT激活每个时间都有一个FCM.
但是,目前,如果应用程序处于后台或非活动状态,则callkit将无法启动.
我正在考虑使用PushKit来实现它.但是,我没有使用PushKit的经验(并且不确定我的应用程序是否会被禁止,根据这篇文章:PushKit:我们可以在聊天应用程序中使用推送套件(VoiP推送)而无需使用VoiP
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
// With swizzling disabled you must let Messaging know about the message, for Analytics
// …Run Code Online (Sandbox Code Playgroud) 我将Firebase升级v3到了,v4但是在接收消息方面遇到了一些问题,我收到了此警告:
[Firebase/Messaging] [I-FCM002019] FIRMessaging收到的数据消息,但是FIRMessagingDelegate的消息:didReceiveMessage:未实现
我知道我应该实现这个方法:
public func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage){
print(remoteMessage.appData)
//let title = remoteMessage.appData[("data"): {"title"}]
var title = "New Request"
for value in remoteMessage.appData{
if let value = value as? [AnyHashable:Any]{
print(value)
}
}
let message = "okay"
print(message)
self.showAlertAppDelegate(title: title ,message:message ,buttonTitle:"ok",window:self.window!)
print(title, message)
}
Run Code Online (Sandbox Code Playgroud)
但是我仍然有警告,所以我应该采取更多行动吗?
我已经在Android应用中实现了FCM推送通知。
当我登录到应用程序时。我收到的通知格式如下。
当应用程序在后台运行时,我会收到json响应,如下所示。
以下是我在onMessageRecieved()中添加的代码
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle("App")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(bitmap))/*Notification with Image*/;
Run Code Online (Sandbox Code Playgroud)
在两种情况下,我如何以相同的方式获取通知。
任何帮助将不胜感激谢谢
android android-notifications firebase firebase-cloud-messaging
在我的应用程序中,我正在提供用户之间的视频和语音通话。我也在使用Firebase Realtime数据库和FCM。
这是我的通知传递的数据:
data: {
channel_id: channel_id,
user_id: user_id
}
Run Code Online (Sandbox Code Playgroud)
在我的FirebaseMessagingService类中,我检索数据并打开Video / Call活动,如下所示:
if(remoteMessage.getData().size > 0) {
Intent intent = new Intent(this, VideoCallActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("channel_id", remoteMessage.getData().get("channel_id"));
intent.putExtra("user_id", remoteMessage.getData().get("user_id"));
getApplicationContext().startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
即使应用程序在后台,一切都可以正常运行。但是,我面临着这个问题:
如果用户在被呼叫时没有互联网连接,则当他连接到互联网时,即使呼叫已被呼叫者中止并且通知已从Firebase实时数据库中删除,他的电话也会自动启动VideoCallActivity。
因此,请问有没有办法取消已发送的通知,或者知道这些通知的传递状态,或者采取其他方式取消?这样,我就可以为用户添加未接来电列表。
谢谢!
我想在我的应用中使用FCM,但是在添加了最新的firebase-messaging依赖项之后:
implementation 'com.google.firebase:firebase-messaging:18.0.0'
Run Code Online (Sandbox Code Playgroud)
构建项目时,在编译器中出现以下错误:
error: cannot find symbol class GetTokenResult
Run Code Online (Sandbox Code Playgroud)
该错误来自于我用来捕获用户令牌的FirebaseUserInterceptor,它工作得很好。但是,添加消息传递依赖性后,“ GetTokenResult”和“ getToken()”似乎都无法识别,因此引发了上述错误。
码:
import android.util.Log;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GetTokenResult;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
public class FirebaseUserInterceptor implements Interceptor {
private static final String X_FIREBASE_ID_TOKEN = "firebaseUserId";
private static final String TAG = "FirebaseUserInterceptor";
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
try {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user == null) {
Log.d(TAG, …Run Code Online (Sandbox Code Playgroud)