In MyAppDelegate.m
@interface MyAppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
{
NSInteger skipforeground;
BOOL allowLandscape;
NSInteger NoCheck;
}
- (UIInterfaceOrientationMask)application:(UIApplication *) application
supportedInterfaceOrientationsForWindow:(UIWindow *) window {
if (self->allowLandscape==true) {
NSLog(@"rotation yes !");
return UIInterfaceOrientationMaskAll;
} else
{
return UIInterfaceOrientationMaskPortrait;
};
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
//Called when a notification is delivered to a foreground app.
NSString *Param=notification.request.content.userInfo[@"scriptParam"];
if ([Param isEqual:@"TurnOffRotation"]) {
self->allowLandscape=false;
}
} else if ([Param isEqual:@"TurnOnRotation"]) {
self->allowLandscape=true;
}
In Filemaker
Configure Local Notification [ Action: Queue ; Name: "RunFunction" ; Script: “EmptyScript” ; Parameter: "TurnOnRotation"; Delay: 0 ]
The code above was used to unlock or lock landscape orientation depending on the layout .
It stopped working for some reason.
The condition is met and I see "rotation yes !" in the log but the screen won't rotate.
If I change the condition for an always true condition like "2>1" the screen will rotate.
As soon as I reference self->allowLandscape in supportedInterfaceOrientationsForWindow the code is executed but the screen does not rotate.
Anyone knows how to fix it ?