moko-permissions icon indicating copy to clipboard operation
moko-permissions copied to clipboard

Invalid permission for REMOTE_NOTIFICATION on iOS

Open ncltg opened this issue 2 years ago • 4 comments

The issue

When calling permissionsController.getPermissionState() with Permission.REMOTE_NOTIFICATION, I always get the same value : DeniedAlways.

I'm testing it by deleting completely my app for my test phone. At the time the call is made no authorization has been requested by the user yet. In fact, just to be sure I also checked into the settings of the app that the Notification setting row does not appear.

What I tested

I first tested to prompt the notification status by logging it in my iOS app that way :

    let currentCenter = UNUserNotificationCenter.current()
    currentCenter.getNotificationSettings { value in
      print(value.authorizationStatus)
    }

Which gives me this output :

<UNNotificationSettings: 0x28002ac70; authorizationStatus: NotDetermined, notificationCenterSetting: NotSupported, soundSetting: NotSupported, badgeSetting: NotSupported, lockScreenSetting: NotSupported, carPlaySetting: NotSupported, announcementSetting: NotSupported, criticalAlertSetting: NotSupported, timeSensitiveSetting: NotSupported, alertSetting: NotSupported, scheduledDeliverySetting: NotSupported, directMessagesSetting: NotSupported, alertStyle: None, groupingSetting: Default providesAppNotificationSettings: No>

Everything is fine here so I moved on with trying to get the value myself from my KMM/iosMain code :

    fun getPermissionState() {
        val currentCenter = UNUserNotificationCenter.currentNotificationCenter()
        currentCenter.getNotificationSettingsWithCompletionHandler { settings: UNNotificationSettings? ->
            Log.debug(settings?.authorizationStatus.toString()) // returns 0 for UNAuthorizationStatus.notDetermined
        }
    }

I get the right result even in the kmm side, while at the same time I still get .DeniedAlways from moko.permissions

Any idea where this issue could originate from ?

ncltg avatar Sep 21 '22 08:09 ncltg

+1! There are multiple issues with iOS Remote notifications, which makes this library for Kotlin Mobile development useless.

@Alex009 we've just merged the Android support for Remote notifications. Can we do the same for iOS as well 😁

petarmarijanovicfive avatar Nov 21 '22 20:11 petarmarijanovicfive

@petarmarijanovicfive you can create PR with fixes. i think now we not have case NotDetermined just because android can't tell us same state

Alex009 avatar Dec 18 '22 09:12 Alex009

i check now on 0.15.0 dev version and i see that getPermissionState return NotDetermined on iOS on clean install image

Alex009 avatar Apr 10 '23 08:04 Alex009

DeniedAlways will be after trying to request permission and user decline this request

Alex009 avatar Apr 10 '23 08:04 Alex009