Nitzan Wilnai
Nitzan Wilnai

Reputation: 943

Handle iOS Memory Warning with PhoneGap

I am really surprised no one has asked this yet: how do I handle iOS memory warnings with PhoneGap?

Specifically, how do I call one of my JS functions when the iOS native application receives a memory warning?

Thanks!

Upvotes: 6

Views: 852

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

You can create a plugin that calls any js function you want, CDVPlugin already have an overridable onMemoryWarning method.

- (void)onMemoryWarning
{
    NSString * javascriptString = @"yourJSFunctionToManageMemoryWarnings();";
    [self.webView stringByEvaluatingJavaScriptFromString:javascriptString];
}

Upvotes: 4

Related Questions