facebook twitter hatena line email

Unity/ローカル通知

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

ローカル通知に使うライブラリ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();

Androidビルド時にenableUncompressedNativeLibsエラー

MobileNotificationがエラーを起こしている。 エラー詳細

WARNING:The option setting 'android.bundle.enableUncompressedNativeLibs=false' is deprecated.
The current default is 'true'.
It will be removed in version 8.0 of the Android Gradle plugin.

対応方法: MobileNotificationを2(2.2.1)系から1.4.4へ

参考

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