EddyVerbruggen / nativescript-admob

NativeScript plugin to earn some precious :moneybag::moneybag: with ads by Google AdMob
MIT License
69 stars 26 forks source link

showInterstitial crashes app #66

Closed szgozcan closed 5 years ago

szgozcan commented 5 years ago

Hi everyone, I have an app in which banners add run perfectly, But I have an issue with interstitials, Preload works and I see on console "interstitial preloaded - you can now call 'showInterstitial' whenever you're ready to do so" but when I hit for showInterstitial, on console I get "JS: interstitial showing" message but the app crashes,

In my app.js file I have killProcess function

application.on(application.suspendEvent, function (args) { 

if (args.android) { 
   // For Android applications, args.android is an android activity class. 
   console.log("Activity: " + args.android); 
   killProcess(args.android);
} else if (args.ios) { 
   // For iOS applications, args.ios is UIApplication. 
   console.log("UIApplication: " + args.ios); 
}
});

 function killProcess(context) {
  // finish current activity and all below it first
  try {
    context.finishAffinity();
  } catch (e) {
  console.log("didn't terminate all activities");
 }
 // kill process
 android.os.Process.killProcess(android.os.Process.myPid());
 }

When I delete killProcess from app.js interstitials works fine. But I want to keep killProcess as well, Is there a way around to deal with this issue.

EddyVerbruggen commented 5 years ago

I guess the interstitial triggers the suspend event which kills the app because of your own logic. So while showing the interstitial simply either don't call killProcess, or detach the suspend listener.