Closed soodohkohd closed 1 year ago
Any update?
still waiting... i might just go back to Flutter
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';
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;
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.
I will give it a try and let you know my results. Thank you!
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();
}
Just published my app to the Apple App Store and downloaded it through TestFlight - works as expected!
I am able to successfully run/test my app in the Simulator and even on my device from my development environment. However, after publishing my app to the Apple App Store and downloading it through TestFlight, the app immediately crashing when launched.
Here's my package.json file:
Environment: Node: 19.7.0 NPM: 9.5.0 NativeScript: 8.4.0 Xcode 14.3 - Build version 14E222b iPhone: 13 mini iOS: 16.4.1
Here's what I have in my Info.plist:
I keep reading (outside of Github) about issues with the Admob package. Is there other options for serving up Google ads on iOS apps using NativeScript?
Here's the crash log from my device: