NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 50 forks source link

App crashes on (iOS) device after installing from TestFlight #209

Closed soodohkohd closed 1 year ago

soodohkohd commented 1 year ago

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:

  "dependencies": {
    "@angular/animations": "15.2.8",
    "@angular/common": "15.2.8",
    "@angular/compiler": "15.2.8",
    "@angular/core": "15.2.8",
    "@angular/forms": "15.2.8",
    "@angular/platform-browser": "15.2.8",
    "@angular/platform-browser-dynamic": "15.2.8",
    "@angular/router": "15.2.8",
    "@nativescript-community/ui-pulltorefresh": "2.5.3",
    "@nativescript/angular": "15.2.0",
    "@nativescript/core": "8.5.0",
    "@nativescript/firebase-admob": "3.1.0",
    "@nativescript/firebase-core": "3.1.0",
    "@nativescript/theme": "3.0.2",
    "nativescript-phone": "3.0.3",
    "rxjs": "7.8.1",
    "zone.js": "0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "15.2.7",
    "@angular/compiler-cli": "15.2.8",
    "@nativescript/android": "8.5.0",
    "@nativescript/ios": "8.5.0",
    "@nativescript/types": "8.5.0",
    "@nativescript/webpack": "5.0.14",
    "@ngtools/webpack": "15.2.7",
    "sass": "1.62.1",
    "typescript": "4.9.5"
  }
    "@nativescript/firebase-admob": "3.1.0",
    "@nativescript/firebase-core": "3.1.0",

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:

image

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:


Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib                 0x1cea64558 __pthread_kill + 8
1   libsystem_pthread.dylib                0x1ef6e2118 pthread_kill + 268
2   libsystem_c.dylib                      0x1972c6c04 __abort + 128
3   libsystem_c.dylib                      0x19726e184 abort + 192
4   libsystem_c.dylib                      0x1972c60a4 __assert_rtn + 272
5   NativeScript                           0x104fbd1b0 tns::Assert(bool, v8::Isolate*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (.cold.1) + 40
6   NativeScript                           0x1044c2744 tns::Assert(bool, v8::Isolate*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 132
7   NativeScript                           0x10449eb9c tns::MetadataBuilder::GlobalPropertyGetter(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&) + 3224
8   NativeScript                           0x10488096c v8::internal::PropertyCallbackArguments::CallNamedGetter(v8::internal::Handle<v8::internal::InterceptorInfo>, v8::internal::Handle<v8::internal::Name>) + 324
9   NativeScript                           0x104876a78 v8::internal::(anonymous namespace)::GetPropertyWithInterceptorInternal(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::InterceptorInfo>, bool*) + 292
10  NativeScript                           0x10497134c v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 104
11  NativeScript                           0x10481aa80 v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, bool, v8::internal::Handle<v8::internal::Object>) + 2380
12  NativeScript                           0x10482392c v8::internal::Runtime_LoadNoFeedbackIC_Miss(int, unsigned long*, v8::internal::Isolate*) + 208
13  NativeScript                           0x104e51e0c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit + 108
14  NativeScript                           0x104ed4580 Builtins_LdaGlobalHandler + 4672
15  NativeScript                           0x104ddfe58 Builtins_InterpreterEntryTrampoline + 248
16  NativeScript                           0x104ddd3c0 construct_stub_create_deopt_addr + 320
17  NativeScript                           0x104ee22f8 Builtins_ConstructHandler + 664
18  NativeScript                           0x104ddfe58 Builtins_InterpreterEntryTrampoline + 248
19  NativeScript                           0x104ddd3c0 construct_stub_create_deopt_addr + 320
20  NativeScript                           0x104ee22f8 Builtins_ConstructHandler + 664
21  NativeScript                           0x104ddfe58 Builtins_InterpreterEntryTrampoline + 248
22  NativeScript                           0x104ddfe58 
.
.
.

Thread 1 name:  V8 DefaultWorke
Thread 1:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   NativeScript                           0x104519368 v8::platform::DelayedTaskQueue::GetNext() + 592
3   NativeScript                           0x104518c98 v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 44
4   NativeScript                           0x10450dc6c v8::base::ThreadEntry(void*) + 100
5   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
6   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 2 name:  V8 DefaultWorke
Thread 2:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   NativeScript                           0x104519368 v8::platform::DelayedTaskQueue::GetNext() + 592
3   NativeScript                           0x104518c98 v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 44
4   NativeScript                           0x10450dc6c v8::base::ThreadEntry(void*) + 100
5   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
6   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 3 name:  V8 DefaultWorke
Thread 3:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   NativeScript                           0x104519368 v8::platform::DelayedTaskQueue::GetNext() + 592
3   NativeScript                           0x104518c98 v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 44
4   NativeScript                           0x10450dc6c v8::base::ThreadEntry(void*) + 100
5   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
6   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 4 name:  V8 DefaultWorke
Thread 4:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   NativeScript                           0x104519368 v8::platform::DelayedTaskQueue::GetNext() + 592
3   NativeScript                           0x104518c98 v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 44
4   NativeScript                           0x10450dc6c v8::base::ThreadEntry(void*) + 100
5   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
6   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 5 name:  V8 DefaultWorke
Thread 5:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   NativeScript                           0x104519368 v8::platform::DelayedTaskQueue::GetNext() + 592
3   NativeScript                           0x104518c98 v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 44
4   NativeScript                           0x10450dc6c v8::base::ThreadEntry(void*) + 100
5   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
6   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 6:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 7:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 10:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 11 name:  com.apple.uikit.eventfetch-thread
Thread 11:
0   libsystem_kernel.dylib                 0x1cea5dc84 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x1cea70b54 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x1cea70e2c mach_msg_overwrite + 540
3   libsystem_kernel.dylib                 0x1cea5e1c8 mach_msg + 24
4   CoreFoundation                         0x18fdbe114 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18fdbf340 __CFRunLoopRun + 1208
6   CoreFoundation                         0x18fdc44dc CFRunLoopRunSpecific + 612
7   Foundation                             0x18a05e0c4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8   Foundation                             0x18a05dfac -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9   UIKitCore                              0x192282dac -[UIEventFetcher threadMain] + 416
10  Foundation                             0x18a077634 __NSThread__start__ + 716
11  libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
12  libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 12:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 13:
0   libsystem_pthread.dylib                0x1ef6dbb74 start_wqthread + 0

Thread 14 name:  JavaScriptCore libpas scavenger
Thread 14:
0   libsystem_kernel.dylib                 0x1cea5e558 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1ef6e3078 _pthread_cond_wait + 1232
2   JavaScriptCore                         0x1a355001c scavenger_thread_main + 1620
3   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
4   libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 15 name:  com.apple.NSURLConnectionLoader
Thread 15:
0   libsystem_kernel.dylib                 0x1cea5dc84 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x1cea70b54 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x1cea70e2c mach_msg_overwrite + 540
3   libsystem_kernel.dylib                 0x1cea5e1c8 mach_msg + 24
4   CoreFoundation                         0x18fdbe114 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18fdbf340 __CFRunLoopRun + 1208
6   CoreFoundation                         0x18fdc44dc CFRunLoopRunSpecific + 612
7   CFNetwork                              0x190fae7e0 0x190d56000 + 2459616
8   Foundation                             0x18a077634 __NSThread__start__ + 716
9   libsystem_pthread.dylib                0x1ef6dc6b8 _pthread_start + 148
10  libsystem_pthread.dylib                0x1ef6dbb88 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x0000000000000036   x7: 0x0000000000000800
    x8: 0xa01fcc7328c2c767   x9: 0xa01fcc72ce8c4627  x10: 0x00000000000003e8  x11: 0x000000000000000a
   x12: 0x0000000000000000  x13: 0x0000000000000036  x14: 0x00000000cd25f016  x15: 0x00000000cd05e86b
   x16: 0x0000000000000148  x17: 0x00000001e64e8140  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000000103  x21: 0x00000001e64e8220  x22: 0x000000010a87c000  x23: 0x0000000105047bf2
   x24: 0x00000001e3537000  x25: 0x0000000000000000  x26: 0x00000001026a7fd9  x27: 0x00000001026a7fd9
   x28: 0x0000000104fcf8e4   fp: 0x000000016dd7bb50   lr: 0x00000001ef6e2118
    sp: 0x000000016dd7bb30   pc: 0x00000001cea64558 cpsr: 0x40001000
   far: 0x00000001056eb58d  esr: 0x56000080  Address size fault

Binary Images:
       0x102070000 -        0x10231bfff dibs arm64  <73332984f710362bb04dfcf039966370> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/dibs
       0x104478000 -        0x1050c7fff NativeScript arm64  <edaa96ef902e31a9985b73bba720d38a> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/NativeScript.framework/NativeScript
       0x102f80000 -        0x102f93fff TKLiveSync arm64  <5299c2cb27c039bc863ce32c65ddf11d> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/TKLiveSync.framework/TKLiveSync
       0x102fd4000 -        0x102fe3fff FBLPromises arm64  <c1b1038ba1d43e158429b214ef48ace3> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/FBLPromises.framework/FBLPromises
       0x10310c000 -        0x103127fff GoogleUtilities arm64  <3803f852f236394c91b519506ff7279d> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/GoogleUtilities.framework/GoogleUtilities
       0x102fa4000 -        0x102fabfff nanopb arm64  <a433a1ee03f5377f9243786ed37db9d6> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/nanopb.framework/nanopb
       0x102fb8000 -        0x102fbffff TNSWidgets arm64  <25cc17c12d2f38b6ad57ffa732f59346> /private/var/containers/Bundle/Application/A1215CB3-BE57-4342-AD2E-ED27A640870D/dibs.app/Frameworks/TNSWidgets.framework/TNSWidgets
       0x103184000 -        0x10318ffff libobjc-trampolines.dylib arm64e  <e57f2d6df3f138fea6c21fb6f6731d4c> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
       0x10424c000 -        0x10425ffff GAXClient arm64e  <48234c0512773470a62e008522535412> /System/Library/AccessibilityBundles/GAXClient.bundle/GAXClient
       0x1cea5d000 -        0x1cea94ff7 libsystem_kernel.dylib arm64e  <5998c9aec77e3681bd6c0883c89297cf> /usr/lib/system/libsystem_kernel.dylib
       0x1ef6db000 -        0x1ef6e6ff3 libsystem_pthread.dylib arm64e  <b1ee57e144843714ba1a104330ca10c6> /usr/lib/system/libsystem_pthread.dylib
       0x197251000 -        0x1972ceff3 libsystem_c.dylib arm64e  <72233fdeddfe3e78b9912dece8cd78c5> /usr/lib/system/libsystem_c.dylib
       0x18fd45000 -        0x19012cfff CoreFoundation arm64e  <6a07cbe84f653dbcb59dc1a188a7b95d> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
       0x18a01c000 -        0x18a8f9fff Foundation arm64e  <35567930fbc2374bb44b1ddfe3ada4a1> /System/Library/Frameworks/Foundation.framework/Foundation
       0x191db3000 -        0x1935d5fff UIKitCore arm64e  <b0858d8e722037bf873fecc2b0a358c3> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
       0x1a343c000 -        0x1a4b64fff JavaScriptCore arm64e  <29cbb1b7b9293711a36a0861e3024d35> /System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore
       0x190d56000 -        0x191120fff CFNetwork arm64e  <b2273be9538a3f56b9c7801f39550f58> /System/Library/Frameworks/CFNetwork.framework/CFNetwork

EOF
Mithat3313 commented 1 year ago

Any update?

soodohkohd commented 1 year ago

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

Mithat3313 commented 1 year ago

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';
soodohkohd commented 1 year ago

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;
Mithat3313 commented 1 year ago

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

soodohkohd commented 1 year ago

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

soodohkohd commented 1 year ago

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();
    }
soodohkohd commented 1 year ago

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