facebook twitter hatena line email

Unity/ローカル通知

提供: 初心者エンジニアの簡易メモ
2021年3月17日 (水) 02:22時点におけるAdmin (トーク | 投稿記録)による版 (以下エラーが出る場合)

移動: 案内検索

ローカル通知に使うライブラリMobile Notificationsをインストール

  1. window/package managerを選択
  2. 左上の+の右ドロップボックスが、InProjectになってれば、UnityRegistoryを選択
  3. Mobile Notificationsを選択
  4. インストール
  5. Assets/Editor/com.unity.mobile.notifications/にインストールされることを確認

設定

  1. Edit/Project Settings/Mobile Notifications

に設定画面がある

androidアイコン設定

  1. Androidタブ選択
  2. Notifications Iconを選択し、png画像をドラッグ&ドロップ
Small Icon 48x48
Large Icon 192x192

以下エラーが出る場合

Specified texture can't be used because:
Read/Write is not enabled in the texture importer.

画像のInspectorのAdvancedを開いて、Read/Write Enabledにチェックを入れるとよい。

参考:https://traitam.hatenablog.com/entry/2020/04/05/133704

csサンプル

以下からLocalPushNotificationを追加

https://qiita.com/syou007/items/dd5cbd8be7590e12f3cf

push通知発行

LocalPushNotification.RegisterChannel("channelId", "アプリ名(チャンネル名)", "説明");
LocalPushNotification.AddSchedule("プッシュ通知タイトル", "内容", 1, 60, "channelId");

push通知削除

LocalPushNotification.AllClear();

参考

https://qiita.com/syou007/items/dd5cbd8be7590e12f3cf