【问题标题】:Sending onesignal notification from flutter从颤振发送一个信号通知
【发布时间】:2019-06-30 20:42:40
【问题描述】:

我有一个使用 Unity 创建的 android 应用程序,我可以从 OneSignal 网站和我的 php 网站成功地向这个应用程序发送通知。现在我想从颤振应用程序(android)发送通知。我尝试了用于颤振示例的 onesignal sdk,但它将通知发送到颤振应用程序而不是 Unity 应用程序。我不知道我哪里错了:

    Future<void> initPlatformState() async {
    if (!mounted) return;



    var settings = {
      OSiOSSettings.autoPrompt: false,
      OSiOSSettings.promptBeforeOpeningPushUrl: true
    };


    // NOTE: Replace with your own app ID from https://www.onesignal.com
    await OneSignal.shared
        .init("9a98990f-40fa-455e-adda-ccd474594f41", iOSSettings: settings);

    OneSignal.shared
        .setInFocusDisplayType(OSNotificationDisplayType.notification);

    bool requiresConsent = await OneSignal.shared.requiresUserPrivacyConsent();

    this.setState(() {
      _enableConsentButton = requiresConsent;
    });
  }





  void _handleSendNotification() async {
    var status = await OneSignal.shared.getPermissionSubscriptionState();

    var playerId = status.subscriptionStatus.userId;

    var imgUrlString =
        "https://vaars.000webhostapp.com/MrNutella/logonutella.png";

    var notification = OSCreateNotification(
        playerIds: [playerId],
        content: "this is a test from OneSignal's Flutter SDK",
        heading: "Test Notification",
        iosAttachments: {"id1": imgUrlString},
        bigPicture: imgUrlString,
        buttons: [
          OSActionButton(text: "test1", id: "id1"),
          OSActionButton(text: "test2", id: "id2")
        ]);

    var response = await OneSignal.shared.postNotification(notification);

    this.setState(() {
      _debugLabelString = "Sent notification with response: $response";
    });
  }

【问题讨论】:

    标签: flutter push-notification onesignal


    【解决方案1】:

    听起来您正在寻找P2P (user-user) 通知。您将需要一种方法从 Flutter 应用中获取目标应用 (Unity) 的播放器 ID。

    【讨论】:

    • 谢谢,但我想向所有通过“管理员”flutter 应用而不是网络安装 Unity 应用的人发送通知。
    • 你好,没错。您需要从 Flutter 应用向 Unity 应用发送 P2P 通知
    猜你喜欢
    • 2020-06-26
    • 1970-01-01
    • 2021-11-04
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 2019-05-31
    • 1970-01-01
    相关资源
    最近更新 更多