6

Is it possible to use python and/or kivy to send local notifications on ios? Really it does not have to vibrate, just a number icon and maybe a real-time message would work.

Edit:

Looking at the comments it seems that Pyobjus would be able to accomplish this, but i am not exactly sure how.

Ugh! my dreams are spoiled. My hackintosh is not yet complete and pybojus needs a mac! So it looks like this is going to be an Android app. But I still have no idea how to do this.

pianist1119
  • 319
  • 1
  • 8
  • 19
  • Of course it can; push notifications are just a form of communication. That's like asking if Python and Kivy can do HTTP. You haven't really provided enough information here. Do you specifically mean Apple Push Notification Service? If so, you probably just need to use the native API. On Android we use pyjnius to call native Java code -- I would assume there is something similar for Kivy on iOS. – kitti Apr 22 '14 at 15:37
  • 1
    http://en.wikipedia.org/wiki/Push_technology http://en.wikipedia.org/wiki/Apple_Push_Notification_Service https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html – kitti Apr 22 '14 at 16:21
  • You'll still need to use pyobjus most likely. http://pyobjus.readthedocs.org/en/latest/ Basically, you'll load any needed frameworks, then use `autoclass` to create a Python proxy to an ObjC class and call the methods just like you would in an ObjC iOS app. – kitti Apr 22 '14 at 19:57
  • The error is caused by app_icon = Drawable.icon, here is the solution https://stackoverflow.com/a/69307364 – Sumit Gupta Oct 23 '21 at 13:03

2 Answers2

8

Since you've changed your topic to android...I can help!

Kivy has a sister project, plyer, providing a platform independent way to access different apis through a single pythonic interface. There are quite a few interfaces implemented for Android, including notifications, so you can use plyer directly and/or look at the code to see how it works.

As it happens I've previously made a short video about the android stuff, which you can find here. It's only a very quick introduction, but might help.

inclement
  • 29,124
  • 4
  • 48
  • 60
  • wow,it seems like kivy has a lot of sister projects *ahem*, python-for-android, *ahem* – pianist1119 Apr 23 '14 at 23:46
  • Nice, I didn't know about this. I've just written my own Java code for using vibration and notifications. :D – kitti Apr 24 '14 at 15:13
  • Im gonna try this soon, but im having problems setting it up! How did you install plyer? it depends on pyjnius apparently but when i run setup.py i get `Unable to determine JDK_HOME` but the JDK_HOME variable is set! Typing `echo $JDK_HOME` yields `/usr/usr/lib/jvm/java-7-openjdk-amd64` – pianist1119 Apr 25 '14 at 12:36
  • How are you trying to use it? On android? – inclement Apr 25 '14 at 19:24
  • i am trying to install it on linux, Ubuntu 12.04 LTS, to develop for android. – pianist1119 Apr 25 '14 at 19:58
  • hmm, and now that i think of it can you schedule notifications? or is there a way to access the android clock api? – pianist1119 Apr 25 '14 at 20:01
  • Yes, you can use pyjnius. This will probably ultimately be wrapped by plyer but isn't yet. – inclement Apr 25 '14 at 22:59
  • @inclement you still have yet to tell me how to install on linux! can you help me? the rest of my app is just about done :) – pianist1119 Apr 26 '14 at 00:34
  • I don't really follow what your problem is. Could you make a separate question saying exactly how you tried to install it and the full content of the error? – inclement Apr 26 '14 at 00:38
  • its a little complicated, give me a day and ill put it in a seperate question, sorry im busy right now. – pianist1119 Apr 26 '14 at 00:41
  • Please see here http://stackoverflow.com/questions/23324991/how-to-install-pyjnius-and-plyer – pianist1119 Apr 27 '14 at 15:09
3

I hope this will help you.

import kivy.app
import plyer

class PushNotificationApp(kivy.app.App):
    def show_notification(self):
        plyer.notification.notify(title='test', message="Notification using plyer")

app = PushNotificationApp()
app.run()
  • Hi, I was trying to implement notification using plyer for an android app. It was working fine for my laptop, i was receiving the notifications, but when I built it for android using buildozer, the app crashes whenever the notification line gets executed... I don't know what is the problem, can you help please ! – dev1ce Apr 23 '21 at 12:58