Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 987
Nitzan Wilnai Avatar asked Nov 09 '14 23:11

Nitzan Wilnai


1 Answers

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];
}
like image 128
jcesarmobile Avatar answered Oct 17 '22 07:10

jcesarmobile