【问题标题】:Send notification to self using the Firebase framework使用 Firebase 框架向自己发送通知
【发布时间】:2016-06-27 06:27:47
【问题描述】:

我想实现向用户发送推送通知的通知测试功能。这在 Parse 中很容易做到,我正在尝试使用 Firebase 框架复制此功能。

[[FIRInstanceID instanceID] getIDWithHandler:^(NSString * _Nullable identity, NSError * _Nullable error) {

            if (error) {
                [self stopWaitingForTestNotification];
            }
            else {
                NSDictionary *payloadDict = @{@"alert": @"Success, Push Notifications are working.", SMAppRemoteNotificationTestNotificationIdentifierKey: @"true"};
                [[FIRMessaging messaging] sendMessage:payloadDict to:identity withMessageID:@"test-notification" timeToLive:10];
            }
        }];

有些人可能不会对这没有在控制台中传递任何通知或错误感到惊讶。这是引用当前用户的错误方式,还是有可能?

【问题讨论】:

    标签: ios objective-c firebase firebase-cloud-messaging


    【解决方案1】:

    您上面的代码试图向服务器而不是设备发送消息,请参阅this documentation

    为了向上游发送消息到服务器,iOS 客户端应用编写消息并调用sendMessage

    如果您尝试将通知从您的设备发送到您的设备。

    1. 您需要一台服务器。
    2. 您的 iOS 应用向服务器发送上游消息。
    3. 服务器向您的 iOS 应用发送下游消息。

    或者如果您只是想测试推送通知 在您的 iOS 应用程序中实现 downstream message 或使用 pod try Firebase 并从 firebase 控制台发送通知

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 2020-05-31
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 2021-05-15
      相关资源
      最近更新 更多