@@ -98,21 +98,31 @@ class PermissionsActivity : Activity() {
98
98
// We need to wait for other activity to show
99
99
if (requestCode == ONESIGNAL_PERMISSION_REQUEST_CODE ) {
100
100
Handler ().postDelayed({
101
- val permission = permissions[0 ]
102
- val granted =
103
- grantResults.size > 0 && grantResults[0 ] == PackageManager .PERMISSION_GRANTED
104
101
val callback =
105
102
requestPermissionService!! .getCallback(permissionRequestType!! )
106
103
? : throw RuntimeException (" Missing handler for permissionRequestType: $permissionRequestType " )
107
- if (granted) {
108
- callback.onAccept()
109
- preferenceService !! .saveBool(
110
- PreferenceStores . ONESIGNAL ,
111
- " ${ PreferenceOneSignalKeys . PREFS_OS_USER_RESOLVED_PERMISSION_PREFIX }$permission " ,
112
- true ,
113
- )
104
+
105
+ // It is possible that the permissions request interaction with the user is interrupted. In this case
106
+ // we will receive empty permissions which should be treated as a cancellation and will not prompt
107
+ // for the permission setting
108
+ val defaultFallbackSetting = false
109
+ if (permissions.isEmpty()) {
110
+ callback.onReject(defaultFallbackSetting )
114
111
} else {
115
- callback.onReject(shouldShowSettings(permission))
112
+ val permission = permissions[0 ]
113
+ val granted =
114
+ grantResults.size > 0 && grantResults[0 ] == PackageManager .PERMISSION_GRANTED
115
+
116
+ if (granted) {
117
+ callback.onAccept()
118
+ preferenceService!! .saveBool(
119
+ PreferenceStores .ONESIGNAL ,
120
+ " ${PreferenceOneSignalKeys .PREFS_OS_USER_RESOLVED_PERMISSION_PREFIX }$permission " ,
121
+ true ,
122
+ )
123
+ } else {
124
+ callback.onReject(shouldShowSettings(permission))
125
+ }
116
126
}
117
127
}, DELAY_TIME_CALLBACK_CALL .toLong())
118
128
}
0 commit comments