A.Goutam
A.Goutam

Reputation: 3494

how is disable screen off when ipa is running

I have an issue with my iOS IPA. i want that while my app is running screen will no off. For this when i googled i get answer that is telling to use UIApplication.sharedApplication().idleTimerDisabled = true. So i try this in AppDelegate.cs. But this is not working in my ios IPA. Because after sometime screen is going to be off. Also the same answer i get on Stackoverflow with high repution

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();
        global::ZXing.Net.Mobile.Forms.iOS.Platform.Init();
        UIApplication.SharedApplication.IdleTimerDisabled = true; 
        formsApp = new App();
        LoadApplication(formsApp);             
        return base.FinishedLaunching(app, options);
    }

Can you please tell what i am doing mistake in my code? Thanks for your solution and code.

Upvotes: 1

Views: 129

Answers (1)

Mark Jenkins
Mark Jenkins

Reputation: 36

It's the right way, although in your case, given the application is one of the passed parameters, you could just call

app.IdleTimerDisabled = true;

I see you're calling

base.FinishedLaunching(app, options);

at the end of your function - I don't use xamarin but it occurs to me that maybe this call is setting it back to false, so you could try calling that first and then setting it to true after:

base.FinishedLaunching(app, options);
app.IdleTimerDisabled = true;
return true;

Upvotes: 1

Related Questions