簡體   English   中英

Flutter - OneSignal 通知

[英]Flutter - OneSignal notification

我在我的 flutter 項目上實現了 OneSignal 設備到設備通知,它適用於 android 設備。

Future<Response> sendNotification(List<String> tokenIdList, String heading, String contents) async{

    return await post(
      Uri.parse('https://onesignal.com/api/v1/notifications'),
      headers: <String, String>{
        'Content-Type': 'application/json; charset=UTF-8',
      },
      body: jsonEncode(<String, dynamic>
      {
        "app_id": kAppId,

        "include_player_ids": tokenIdList,

        "android_accent_color":"FF9976D2",

        "small_icon":"ic_stat_onesignal_default",

        "large_icon":"https://www.filepicker.io/api/file/zPloHSmnQsix82nlj9Aj?filename=name.jpg",

        "headings": {"en": heading},

        "contents": {"en": contents},

      }),
    );
  }

但是當應用程序關閉(從后台殺死)時,通知會正常工作,比如

在此處輸入圖像描述

但是當應用程序運行時,相同的通知看起來像應用程序內消息

在此處輸入圖像描述

我想要通知,而不是應用內消息。 以及更改應用內消息布局的方式。

OneSignal.shared.consentGranted(true);
OneSignal.shared.setInFocusDisplayType(OSNotificationDisplayType.notification);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM