Kivy use Android Notifications
Asked Answered
E

3

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.

Eaves answered 22/4, 2014 at 12:5 Comment(4)
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.Chili
en.wikipedia.org/wiki/Push_technology en.wikipedia.org/wiki/Apple_Push_Notification_Service developer.apple.com/library/ios/documentation/…Chili
You'll still need to use pyobjus most likely. 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.Chili
The error is caused by app_icon = Drawable.icon, here is the solution stackoverflow.com/a/69307364Polyzoan
P
9

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.

Phil answered 23/4, 2014 at 21:44 Comment(11)
wow,it seems like kivy has a lot of sister projects ahem, python-for-android, ahemEaves
Nice, I didn't know about this. I've just written my own Java code for using vibration and notifications. :DChili
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-amd64Eaves
How are you trying to use it? On android?Phil
i am trying to install it on linux, Ubuntu 12.04 LTS, to develop for android.Eaves
hmm, and now that i think of it can you schedule notifications? or is there a way to access the android clock api?Eaves
Yes, you can use pyjnius. This will probably ultimately be wrapped by plyer but isn't yet.Phil
@Phil 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 :)Eaves
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?Phil
its a little complicated, give me a day and ill put it in a seperate question, sorry im busy right now.Eaves
Please see here #23325491Eaves
L
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()
Lyricism answered 19/10, 2019 at 17:34 Comment(1)
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 !Colonist
P
0

You can do this:

from plyer.platforms.android.notification import AndroidNotification

notify = AndroidNotification()
notify.notify(title="Hello", message="yooo")

Don't forget to add permission POST_NOTIFICATIONS.

Phospholipide answered 29/7 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.