OneSignal Notifications + Android 13 + Asking for permission

I decided to make this a new post, since I’ve been kind of off topic asking this around since yesterday.

I’m using Sumit’s OneSignal Extension succesfully to make my app receive push notifications published with OneSignal via a custom PHP back-end. So, app workflow goes like this: “PHP backend POST to → OneSignal that sends notification to → Android device with app installed”.

This solution is working ok. But Android 13 devices all show on the OneSignal dashboard with status “Permission Not Granted”. In my Android 13 testing device, I cannot receive notifications until I go to the settings for applications and manually allow notifications permission for my app.

Other Android version devices receive notification normally just after installing the app and launching it for the first time. So, I guess implementarion is ok other than permission-wise.

I am currently asking for permission like this:
image

The problem is, on the Android 13 testing device, it doesn’t show any dialog prompting the user to allow the permission when running the app for the first time as expected.

I could get this prompt to work by exporting an APK and editing it on APK Studio Editor, which allows me to change Target SDK to 33. Then, with this modified APK installed on the Android 13 device, the permission popup shows correctly to the user after installation and starting the app for the firt time.

But that wouldn’t allow me to publish to Google Play, since I can’t convert modified APK to AAB (tried some solutions to convert APK to AAB found in forums, but couldn’t make them work).

I’m writing in the hope of someone who knows a solution for this. Either by making permission prompt show correctly without having to target SDK 33, or by making Kodular export AAB targeting SDK 33, or by pointing me to a solution to convert modified APK to AAB correctly.

I appreciate any help and, as always, will post solution here once I find it.

Thank you!

I found a temporary workaround in this guide:

It still works for targeting SDK 33. I was able to export APK from Kodular, then edit target SDK with APK Studio Editor (be sure to use latest version) and then transfer it to my phone where I converted it to AAB using APK to AAB Converter (installed from Google Play) and sign it using ZipSigner (installed from the link provided on the video description).

AAB could be uploaded and validated to Google Play. Not the ideal solution but it gets it done for now.

Now, I’m having another issue after targeting SDK 33 where my app can’t get “READ_EXTERNAL_STORAGE” permission. Tried acquiring it like this:

image

But with no luck. I’ll be digging into it next and if I find a solution I’ll post it here to close the topic.

If anyone has any idea on this “READ_EXTERNAL_STORAGE” thing, any help would be appreciated.

Thanks.

Taifun

Oh, so it was deprecated.

I’ll try this soon and get back here with the results.

Thank you!

This post was flagged by the community and is temporarily hidden.

I’m still not able to figure it out. A dialog for READ_MEDIA_IMAGES does not appear and my default code shows the warning about permission being denied.

The blocks go like this:

So, to clarify, the steps are:
1 - Initialize block asks for notification permission through extension’s “AskPermission” call. This is working ok and the user is able to allow it;
2 - When PermissionGranted occours, I’m asking from READ_MEDIA_IMAGES via AskForPermission block. This one does not show any dialog and goes directly to Permission Denied block on the left, which displays the Alert showing it was denied;

Any ideas would be welcome.
Thank you for your help!

Did you declare that permission also in the manifest?
Taifun

I eventually came to this conclusion and made the following changes to the manifest:

image

READ_EXTERNAL_STORAGE was already included by Kodular, so I just added the criteria maxSdkVersion, as it was triggering a “permission denied” message on Android 13 device.

I added READ_MEDIA_IMAGES manually and the permission was asked correctly. So I think that was a progress.

But now I seem to have created two other problems:

1 - I’m using Image_Utilities’s LoadImageAsync block from inside a dynamic created list, like this:

Image source is from a URL. It was working just fine until I started playing with SDK33 stuff and now images are not loading.

I also get some duplicated ID errors from this dynamic list but my guess is that this is due to the LoadImageAsync doing something funny under the hood, since it was all good up until now and blocks are the same.

2 - Application is not working on Android <13… so maybe I did something wrong in the manifest or with the permissions asking?

I’m kinda worried right now, seems like I’m making things worse. lol…
Thank you again for the attention so far.

I got some things sorted out. It turns out I had a bug on my blocks that made screen initialize before the permissions cycle ended, so Image_Utilities started doing funny stuff.

To sum it up: I was able to replace “READ_EXTERNAL_STORAGE” to “READ_MEDIA_IMAGES” for SDK33 onward. That allowed me to edit APK targeting SDK33 and then POST_NOTIFICATIONS (via OnseSinal . AskPermission) could be granted correctly. Now my Android 13 test device is showing as subscribed ok on OneSignal Dashboard.

Two things left:
1 - Test on Android <13 devices. I’ll be doing that later but my guess is it should be ok. If I have any issues with that, that would be a new topic.

2 - When I uninstall and reinstall the application without just updating it from a previous SDK31 installation, permission dialogs popup ok. But after allowing READ_MEDIA_IMAGES, my error catching block still catches “READ_EXTERNAL_STORAGE” being denied and Image_Utilities LoadImageAsync fails to work. Maybe Image_Utilities is hardcode asking for “READ_EXTERNAL_STORAGE”? I guess I’ll have to make a new topic on this.

Is the author of Image_Utilities in this forum? Does anyone have experience using LoadImageAsync within Android 13?

And again, thanks @Taifun for taking the time to help me on this.

2 Likes

Oh, also: LoadImageAsync is failing only with images from external URL. It is loading fine when the image comes from the local assets.

I switched Image_Utilities for @DevYB 's Image Loader for asynchronous image loading and it seems to be working fine now.

Here’s the link:

Will do Android<13 testing today and hopefully I’ll be closing this issue soon.

hey please sort it out. How’s your one signal permission granted or denied is working?

1 Like