Bug with MotionPermission
ogezue opened this issue · comments
I'm trying to use PermissionScope with Objective C and configure it to request for Motion, Location and Notification. I get a non deteministic behavior.
Sometimes PermissionScope is displayed after I open the UI a second time. Sometimes I'm in an endless loop of private func triggerMotionStatusUpdate() {}
that gets called in self.permissionScope = [[PermissionScope alloc] init];
. This results in a white screen and the iOS permission alert is visible when quitting the app.
Is the code below not correct or is this a bug in PermissionScope?
- (void)showPermissions{
self.permissionScope = nil;
self.permissionScope = [[PermissionScope alloc] init];
self.permissionScope.headerLabel.text = NSLocalizedString(@"permission_header",nil);
self.permissionScope.bodyLabel.text = NSLocalizedString(@"permission_body",nil);
[self.permissionScope.closeButton setTitle:NSLocalizedString(@"Close",nil) forState:UIControlStateNormal];
// Set up permissions
[self.permissionScope addPermission:[[LocationWhileInUsePermission alloc] init] message:NSLocalizedString(@"LocationWhileInUsePermissionMessage",nil)];
[self.permissionScope addPermission:[[MotionPermission alloc] init] message:NSLocalizedString(@"MotionPermissionMessage",nil)];
[self.permissionScope addPermission:[[NotificationsPermission alloc] initWithNotificationCategories:nil] message:NSLocalizedString(@"NotificationsPermissionMessage",nil)];
// Styles
[self.permissionScope setLabelFont:[Styling fontDescription]];
[self.permissionScope setButtonFont:[Styling fontDescription]];
[self.permissionScope.headerLabel setFont:[Styling fontValue]];
[self.permissionScope.bodyLabel setFont:[Styling fontDescription]];
[self.permissionScope.closeButton setFrame:CGRectMake(0, 0, 100, 20)];
[self.permissionScope setCloseOffset:CGSizeMake(-20, 0)];
[self.permissionScope show:^(BOOL finished, NSArray<PermissionResult *> * _Nonnull results) {
NSLog(@"show");
} cancelled:^(NSArray<PermissionResult *>* _Nonnull results) {
NSLog(@"cancelled");
}];
}
Possibly a similar case to #147? Looks like you're doing things correctly so likely some issue with the async motion request.