EddyVerbruggen / nativescript-admob

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

plugin does not work on iOS #62

Closed mohamnag closed 5 years ago

mohamnag commented 5 years ago

using tns version 5.3.1 and running on iOS 12.1, I can't get the basic setup of this plugin running. I'm always getting following error in the logs:

CONSOLE LOG file:///app/tns_modules/nativescript-admob/admob.js:145:18: Error in admob.createBanner: TypeError: GADRequest.request is not a function. (In 'GADRequest.request()', 'GADRequest.request' is undefined)
CONSOLE LOG file:///app/app/admob.service.js:40:24: admob createScreenBottomBanner error: TypeError: GADRequest.request is not a function. (In 'GADRequest.request()', 'GADRequest.request' is undefined)
EddyVerbruggen commented 5 years ago

Plz share a repo showing the issue, and reopen. But first try removing the platforms folder, and don't run this inside the Preview app.

bowlesns commented 5 years ago

I'm getting this error too. I'm using a button that calls the function

import * as Admob from "nativescript-admob";

        createBanner() {
            Admob.createBanner({
                testing: true,
                size: Admob.AD_SIZE.MEDIUM_RECTANGLE,
                iosBannerId: "<USING-TEST-AD-ID>",
                // androidBannerId: this.androidBannerId,
                // iosTestDeviceIds: ["<ADDED-SIMULATOR'S ID>"],
                margins: {
                    bottom: 0
                }
            }).then(function() {
                console.log("admob createBanner done");
            }, function(error) {
                console.log("admob createBanner error: " + error);
            });
        }

I deleted the platforms folder and did a pod repo update as well. Does the plugin not work with the iphone simulator, or am I doing something wrong? Any help would be greatly appreciated!

mohamnag commented 5 years ago

@bowlesns I didn't manage to make it run either. for now I gave up as iOS is not my main concern but if anyone found a way to make it run it might be nice to have it up and running.

One thing that could help might be setting the view property explicitly. I took a short look at the code and it seems if view is not set, it will try to find a proper one automatically, might be that does not work.

bowlesns commented 5 years ago

@mohamnag @EddyVerbruggen I figured out what the issue was for me. My tns-ios version was 5.3.1 as well, after changing to 5.1.0 it works properly.

If anyone stumbles upon this, you can change this in the package.json file in the root of your {N} project. Remember to remove package-lock.json, and delete the platforms/ios and node_modules directories in your project prior to build/run.

mohamnag commented 5 years ago

@bowlesns thanks for letting me know. this is definitely no solution but will do as for now. However I can imagine soon this will bring other problems as TNS moves on.

EddyVerbruggen commented 5 years ago

Yeah I agree. The question is: which exact version of tns-ios started to become incompatible. If we know that, it will probably be easier to pinpoint the exact change in tns-ios caused the incompatibility.

mohamnag commented 5 years ago

The thing is, that it seems to me it also stopped showing ads even on Android. Some of the users of my app who know me, reported that ads are not showing up in recent version of the app. I have to investigate more but it seems the functionality is not very stable even in Android.

On Mon, May 6, 2019, 09:32 Eddy Verbruggen notifications@github.com wrote:

Yeah I agree. The question is: which exact version of tns-ios started to become incompatible. If we know that, it will probably be easier to pinpoint the exact change in tns-ios caused the incompatibility.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/nativescript-admob/issues/62#issuecomment-489525304, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCGDDNWZ5TKIHGMGTWVMADPT7NJTANCNFSM4HHO65HA .

EddyVerbruggen commented 5 years ago

If I were you I'd contact AdMob and ask them what's up with your app id's. It's not uncommon for them to suspend apps receiving ads because of unexpected/strange activity.