Coder Social home page Coder Social logo

Comments (8)

Mithat3313 avatar Mithat3313 commented on September 21, 2024

Any update?

from firebase.

soodohkohd avatar soodohkohd commented on September 21, 2024

still waiting... i might just go back to Flutter

from firebase.

Mithat3313 avatar Mithat3313 commented on September 21, 2024

I fixed the issue by changing polyfills.ts file like below,

/**
 * NativeScript Polyfills
 */

// // Install @nativescript/core polyfills (XHR, setTimeout, requestAnimationFrame)
// import '@nativescript/core/globals';
// // Install @nativescript/angular specific polyfills
// import '@nativescript/angular/polyfills';

// /**
//  * Zone.js and patches
//  */
// // Add pre-zone.js patches needed for the NativeScript platform
// import '@nativescript/zone-js/dist/pre-zone-polyfills';

// // Zone JS is required by default for Angular itself
import 'zone.js';

// // Add NativeScript specific Zone JS patches
// import '@nativescript/zone-js';

from firebase.

soodohkohd avatar soodohkohd commented on September 21, 2024

By changing my polyfills.ts file as you have indicated creates another issue (locally).

Any http service call now gets the following error: TypeError: Cannot read properties of undefined (reading 'call')

Here's the method that I use for my http "Get" calls:

        const stream$ = this.get(endpoint, { responseType: type });

        let results = lastValueFrom(stream$).then((value: any) => {
            return value;
        }).catch((error: any) => {
            return error;
        });

        return results;

from firebase.

Mithat3313 avatar Mithat3313 commented on September 21, 2024

Since I faced the same situation, I used the Nativescript HTTP module. If you are not sending an ICMP request, you may consider using it. I couldn't find any other solution for now.

https://docs.nativescript.org/http.html#http

from firebase.

soodohkohd avatar soodohkohd commented on September 21, 2024

I will give it a try and let you know my results. Thank you!

from firebase.

soodohkohd avatar soodohkohd commented on September 21, 2024

For anyone who is interested, I decided to eliminate the firebase packages and just write my own little service to handle Google Ads.

Currently, I only have Interstitial ads for iOS using the latest version of pod 'Google-Mobile-Ads-SDK' (which is 10.5.0 at this time).

First thing to do, add a Podfile to your App_Resources/iOS folder:

platform :ios, '12.0'

pod 'Google-Mobile-Ads-SDK'

Then create an injectable service to handle the ads:

/******************************************************************************
 * Google Admob Interstitial.
******************************************************************************/
import { Injectable } from '@angular/core';

import { isIOS, isAndroid } from "@nativescript/core/platform";
import { getNumber, setNumber } from '@nativescript/core/application-settings';

declare var UIApplication, UISplitViewController, UINavigationController, UITabBarController, GADRequest, GADInterstitialAd;

@Injectable({
    providedIn: 'root'
})
export class AdmobService {
    private androidBannerId: string = "ca-app-pub-00000/00000";
    private androidInterstitialId: string = "ca-app-pub-00000/00000";
    private iosBannerId: string =  "ca-app-pub-00000/00000";
    private iosInterstitialId: string = "ca-app-pub-00000/00000";
    private keywords: string[] = ["news", "top news", "politics", "business", "finance", "social media"];

    public showAd() {
        let adCount = getNumber("_adcount", 0);

        if (adCount >= 3) {
            adCount = 0;
        }

        if (adCount === 0) {
            if (isIOS) {
                this.showIOSAd();
            }
        }

        adCount++;

        setNumber("_adcount", adCount);
    }

    private showIOSAd() {
        let request = GADRequest.request();

        request.keywords = this.keywords;

        GADInterstitialAd.loadWithAdUnitIDRequestCompletionHandler(this.iosInterstitialId, request, (ad: any, error: any) => {
            if (!error) {
                ad.presentFromRootViewController(topViewController());
            }
        });
    }
}

export const topViewController = () => {
    const root = rootViewController();

    if (root == null) {
        return undefined;
    }

    return findTopViewController(root);
};

const rootViewController = () => {
    const app = UIApplication.sharedApplication;
    const window = app.keyWindow || (app.windows.count > 0 && app.windows[0]);

    return window != null ? window.rootViewController : undefined;
};

const findTopViewController = (root: any) => {
    const presented = root.presentedViewController;

    if (presented != null) {
        return findTopViewController(presented);
    }

    if (root instanceof UISplitViewController) {
        const last = root.viewControllers.lastObject;

        if (last == null) {
            return root;
        }

        return findTopViewController(last);
    }
    else if (root instanceof UINavigationController) {
        const top = root.topViewController;

        if (top == null) {
            return root;
        }

        return findTopViewController(top);
    }
    else if (root instanceof UITabBarController) {
        const selected = root.selectedViewController;

        if (selected == null) {
            return root;
        }

        return findTopViewController(selected);
    }
    else {
        return root;
    }
};

Finally, call the 'showAd()' method from the constructor of the view/page you want to load the ad in:

	import { AdmobService } from '~/services/admob.service';

	constructor(private admobService: AdmobService) {
		this.admobService.showAd();
	}

from firebase.

soodohkohd avatar soodohkohd commented on September 21, 2024

Just published my app to the Apple App Store and downloaded it through TestFlight - works as expected!

from firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.