Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority not working on Android version 8 and above #54

Open
Hypocrate-code opened this issue Oct 8, 2023 · 4 comments
Open

Priority not working on Android version 8 and above #54

Hypocrate-code opened this issue Oct 8, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Hypocrate-code
Copy link

Hypocrate-code commented Oct 8, 2023

Hey !
I resolved the previous issues i had,
Now i get it working in some ways, but i need help for a few details :

  1. Here is my code in python :
@mainthread 
def send_notification(content):
    print("notification about to be sent")
    create_notification(
        small_icon=get_resource("drawable").ic_launcher,
        channel_id="ch1",  # you must set this to any string value of your choice
        title="HypLoad",  # title of your notification
        text=f"{content}",  # notification content text
        ids=1,  # notification id, can be used to update certain notification
        channel_name=f"message",
        action_title1="action1",
        priority=NotificationCompat().PRIORITY_MIN
    )
    print("notification sent")

I use the decorator @mainthread to get it working, because notifications have to be sent with the main thread, otherwise i get all the problems i was talking about before (can't use create_notification because the function can't access some androidx and android values)
Whereas, i want the notification to be sent when the app is left but still opened
But if i launch them with the main thread, they only appear when i go back to the app, because the main thread is stopped when the app is left.
So do you have any ideas on how i could proceed to have notifications sent when the app is active but not opened ?

  1. When i use get_resource("drawable").ic_launcher (ic_launcher.png being my resource added as a drawable), the icon appears but is totally grey, instead of having its colors of origin.

  2. NotificationCompat().PRIORITY_MIN works just as NotificationCompat().PRIORITY_LOW that works just as if no priority was set. How can i get it working (i don't want it to show up on the screen, but just to appear in the status bar)

IMPORTANT FACT : with android.api = 34, for me, create_notification was not creating any error but didn't do anything. Now that i have android.api = 32, notifications are sent but i still have issues mentionned above

Thanks for your time

@Hypocrate-code Hypocrate-code changed the title Notification on a different thread, and small_icon problem Sending notification on a different thread, small_icon problem, and priority not working Oct 8, 2023
@Hypocrate-code
Copy link
Author

@kengoon

@kengoon
Copy link
Member

kengoon commented Oct 9, 2023

@Hypocrate-code Using android API 34, you have to add the the POST_NOTIFICATION permission to your buildozer permission and also request for it too.

For the grey icon, that has nothing to do with kvdroid, watch this video to understand how to solve your issues

For the priority, it only works on Android version 7 below. Feature update would be added for android version 8 above

@kengoon kengoon changed the title Sending notification on a different thread, small_icon problem, and priority not working Priority not working on Android version 8 and above Oct 9, 2023
@kengoon kengoon self-assigned this Oct 9, 2023
@kengoon kengoon added the enhancement New feature or request label Oct 9, 2023
@kengoon kengoon added this to the 0.4.0 milestone Oct 9, 2023
@Hypocrate-code
Copy link
Author

Hypocrate-code commented Oct 9, 2023

Thanks for your answers !
I'll try it out asap,
Did you understand the problem with threads/sending notification when the app is opened and left ? Do you need more context ?

@kengoon
Copy link
Member

kengoon commented Oct 9, 2023

@Hypocrate-code use a service to send notifications, services run in the background. Don't ask me how to use service, go and figure that out on your own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants