标签: firebase-notifications

如何取消注册firebase推送注册令牌?

我是一名后端网络开发人员。我正在尝试使用 firebase 进行推送通知,但我开始想知道应用程序客户端是否停用了他的帐户,那么我可以删除客户端的注册令牌,但是否也可以请求 FCM 删除我保存在其中的客户端推送令牌数据库?

http firebase firebase-cloud-messaging firebase-notifications

5
推荐指数
0
解决办法
464
查看次数

FCM:如果用户订阅了多个主题,如何避免重复通知

假设用户 A 订阅了主题 T1、T2 和 T3。

如果我向主题 T1 和 T3 发送相同的通知。A会收到两个通知吗?

如果是这样,如何避免这种重复通知?

谢谢

subscribe firebase firebase-cloud-messaging firebase-notifications

5
推荐指数
1
解决办法
2070
查看次数

如何为此 Firebase Android 项目添加“大文本”或“收件箱样式”通知?

我正在尝试从 Firebase 控制台发送推送通知,目前我可以从 Firebase 控制台向我的虚拟设备发送消息,但如果消息很长,则不会完全显示在通知栏中。

这是 Firebasemessagingservice 的代码:

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

import com.google.firebase.messaging.RemoteMessage;

/**
 * Created by filipp on 5/23/2016.
 */
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService{

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        showNotification(remoteMessage.getData().get("message"));
    }

    private void showNotification(String message) {

        Intent i = new Intent(this,MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setAutoCancel(true)
                .setContentTitle("Elit")
                .setContentText(message)
                //.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentIntent(pendingIntent);

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        manager.notify(0,builder.build());
    }


}
Run Code Online (Sandbox Code Playgroud)

感谢 Adib 的详细回答,我已经有一个 PHP 后端服务器,但是每当我尝试从服务器发送长通知时,它都不会完全显示,我的问题是我是否可以只编辑代码的最后一部分,以便我可以发送长通知使用 inboxStyle 或 …

android push-notification android-notifications firebase firebase-notifications

5
推荐指数
1
解决办法
4902
查看次数

Firebase 推送通知在收到通知时增加徽章计数

我正在使用 iOS 10 和 swift 2.3,当收到来自 firebase 的新通知时,我需要增加徽章计数。我有增加徽章数量的代码

let badgeCount: Int = BadgeCount + 1
UIApplication.sharedApplication().applicationIconBadgeNumber = badgeCount
Run Code Online (Sandbox Code Playgroud)

但我不知道在哪里使用它才能使其正常工作。

push-notification ios swift firebase-notifications

5
推荐指数
1
解决办法
7273
查看次数

如何使用 Firebase 从 Android 应用程序发送推送通知?

我想在我的应用程序中开发一个新功能,让我向所有安装了该应用程序的用户发送通知。我一直在搜索并找到有关如何将上游消息发送到 Firebase Cloud Messaging 的信息,但没有找到任何解释如何直接向其他用户发送通知的信息。

java android firebase firebase-cloud-messaging firebase-notifications

5
推荐指数
1
解决办法
6712
查看次数

没有看到“已打开”Firebase 通知统计信息

我通过覆盖 FirebaseMessagingService 的 onHandle 意图来手动处理 Firebase 通知。

并使用意图生成通知。

有没有办法手动报告打开到 Firebase 的通知,因为我没有将打开的统计信息报告回 Firebase 控制台。

如上所述,即使让 firebase 通知按正常方式处理,这些打开的通知也不会被报告。

谢谢!

firebase firebase-cloud-messaging firebase-notifications

5
推荐指数
1
解决办法
6586
查看次数

iOS:通过 url 请求向 firebase 服务发送推送通知

我正在构建一个测试应用程序来发送推送通知,这是我的代码:

static func sendRequestPush(){
        let json: [String: Any] = ["to": "key",
                                   "priority": "high",
                                   "notification": ["body":"Hello1", "title":"Hello world","sound":"default"]]
    let urlStr:String = "https://fcm.googleapis.com/fcm/send"
    let url = URL(string:urlStr)
    let jsonData = try? JSONSerialization.data(withJSONObject: json)
    var request = URLRequest(url: url!)
    request.httpMethod = "POST"
    request.httpBody = jsonData
    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        guard let data = data, error == nil else {
            print(error?.localizedDescription ?? "No data")

            return
        }
        let responseJSON = try? JSONSerialization.jsonObject(with: data, options: [])
        if let responseJSON = …
Run Code Online (Sandbox Code Playgroud)

ios swift firebase-notifications

5
推荐指数
1
解决办法
1188
查看次数

firebase 不总是通过 APNs 发送通知吗?

我注意到firebase文档说明如下:

如果提供了通知负载,或者将content_available 选项设置为true以将消息发送到 iOS 设备,则消息通过 APNs 发送,否则通过 FCM 连接服务器发送

有人可以解释一下这是什么意思吗?

我以为发送到 iOS 设备的所有推送通知,首先发送到Apple,然后由 Apple 转发到相应的设备,但这里暗示他们直接向设备发送消息?

当应用程序在 iOS 上关闭时,这甚至可能吗?

我很困惑,谢谢。

apple-push-notifications ios firebase firebase-cloud-messaging firebase-notifications

5
推荐指数
1
解决办法
1081
查看次数

通知 - 清除 android 通知托盘中的所有通知

我正在向我的应用程序发送多个通知。我想要实现的是每当用户单击一个通知时,通知托盘中的所有通知都会消失。

我试过添加

notification.android.setAutoCancel(true)
Run Code Online (Sandbox Code Playgroud)

它只对一个通知(被点击的那个)起作用

我也试过:

firebase.notifications().removeAllDeliveredNotifications() 
Run Code Online (Sandbox Code Playgroud)

这没有任何影响。

我怎样才能做到这一点?

这是我的完整代码:

      componentDidMount() {
    firebase.notifications().removeAllDeliveredNotifications()

    this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
    });

    this.notificationListener = firebase.notifications().onNotification(async (notification) => {
      // Process your notification as required
      notification.android.setAutoCancel(true)
      firebase.notifications().removeAllDeliveredNotifications()
  }



    async componentWillMount() {
    this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
    });
    this.notificationListener = firebase.notifications().onNotification((notification) => {
    });

    this.notificationDisplayedListener();
    this.notificationListener();
    }
Run Code Online (Sandbox Code Playgroud)

android-notifications react-native firebase-cloud-messaging firebase-notifications react-native-firebase

5
推荐指数
1
解决办法
861
查看次数

SwiftUI 通知单击转到特定视图

我正在使用 SwiftUI 2.0,我正在尝试实现 firebase 推送通知。在新的 SwiftUI 应用程序结构中,没有 AppDelegate 和 SceneDelegate,因此我创建了 AppDelegate 类。我设法接收通知,但无法在单击通知时转到特定视图。这是我的代码:

@main
struct swiftUiApp: App {


@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate


var body: some Scene {
    WindowGroup {
       
            ContentView() 
         
    }
  } 
}
Run Code Online (Sandbox Code Playgroud)

和 AppDelegate 扩展:

func userNotificationCenter(_ center: UNUserNotificationCenter,
                          didReceive response: UNNotificationResponse,
                          withCompletionHandler completionHandler: @escaping () -> Void) {

let  orders =  Orders()

let userInfo = response.notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
  print("Message ID: \(messageID)")
}

if(userInfo["gcm.notification.type"] != nil){
    if(userInfo["gcm.notification.type"] as! String == "order"){
  
          //here I …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase-notifications swiftui ios14

5
推荐指数
2
解决办法
2704
查看次数