0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

『個人開発記録』MacOSでの通知でplyerを不採用にした理由

Last updated at Posted at 2025-07-30

初めに

個人開発で作成したチャットツールに通知機能を実装するため、当初はService Workerを検討しましたが、学習コストを考え、より手軽そうなPythonライブラリ「Plyer」を試すことにしました。
しかし結論から言うと、特にmacOS環境において解決が難しい問題に直面したため、今回はPlyerの採用を見送りました。本記事では、その技術選定の過程と理由を正直に記録します。

plyerとは

Plyer is a platform-independent Python API for accessing hardware features of various platforms (Android, iOS, macOS, Linux and Windows).

と書いてあり翻訳して見ると

Plyer は、さまざまなプラットフォーム (Android、iOS、macOS、Linux、Windows) のハードウェア機能にアクセスするための、プラットフォームに依存しない Python API です。

と書いてあります。今回はその中にあるNotificationsを使用して通知を実装します。

plyerのインストール

ライセンスはMITライセンスです。

pip install plyer

macの場合
macの場合このライブラリーがないとエラーを吐かれるので入れておきましょう。
同じくらいセンスはMITライセンスです。

pip install pyobjus

使い方

from plyer import notification

notification.notify(
    title='タイトル',
    message='message',
    app_name='アプリの名前',
    app_icon='unnamed.ico',#なぜかmacではできなかった
    timeout=5,
)
  • title: 通知のタイトル
  • message: 通知の本文
  • app_name: どのアプリからの通知かを示す名前
  • app_icon: 通知に表示するアイコンのパス
  • timeout: 通知が表示される秒数

理由

  • macOSでapp化したがエラーが出て実行できない(ソースコードでは動作する)
  • macOSでアイコンが表示(変更)されない

理由1:macOSでapp化したがエラーが出て実行できない(ソースコードでは動作する)

実行したコマンド

pyinstaller test.py --hidden-import plyer.platforms.win.notification
NotImplementedError: No usable implementation found!

理由2:macOSでアイコンが表示(変更)されない

webサイトからひっぱてきても.icoでもアイコンが変わりませんでした。

notification.notify(
    title='タイトル',
    message='message',
    app_name='アプリの名前',
    app_icon='unnamed.ico',#なぜかmacではできなかった
    timeout=5,
)

解決策を知っている方がいましたら教えていただければありがたいです。

0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?