NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
190 stars 109 forks source link

[@nativescript/facebook] ios: FacebookAppID not found #191

Closed Spasfonx closed 2 years ago

Spasfonx commented 3 years ago

The issue

Hello,

On iOS, when I'm using the @nativescript/facebook plugin, I've this error message :

App ID not found. Add a string value with your app ID for the key FacebookAppID to the Info.plist or call FBSDKSettings.sharedSettings.appID.
Error: App ID not found. Add a string value with your app ID for the key FacebookAppID to the Info.plist or call FBSDKSettings.sharedSettings.appID

My configuration

I'm using Nativescript with angular.

// main.ts
import { platformNativeScript, runNativeScriptAngularApp } from '@nativescript/angular';
import { LoginManager } from '@nativescript/facebook';
import { enableProdMode } from '@angular/core';

import { AppModule } from './app/app.module';

enableProdMode()

LoginManager.init()

runNativeScriptAngularApp({
  appModuleBootstrap: () => platformNativeScript().bootstrapModule(AppModule),
});
// mycomponent.component.ts
public async facebookLogin() {
        try {
            const result = await LoginManager.logInWithPermissions(['public_profile'])
            ...
// Info.plist
<key>CFBundleURLTypes</key>
<array>
   <dict>
    <key>CFBundleTypeRole</key>
        <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>fbXXXX</string>
    </array>
   </dict>
</array>
<key>FacebookAppID</key>
<string>XXXXX</string>
<key>FacebookDisplayName</key>
<string>XXXXXX</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<string>TRUE</string>
<key>FacebookAdvertiserIDCollectionEnabled</key>
<string>TRUE</string>
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
     </array>
┌───────────────────────────────────┬─────────────────┐
│ Plugin                            │ Version         │
│ @angular/animations               │ ^12.2.0         │
│ @angular/common                   │ ^12.2.0         │
│ @angular/compiler                 │ ^12.2.0         │
│ @angular/core                     │ ^12.2.0         │
│ @angular/forms                    │ ^12.2.0         │
│ @angular/platform-browser         │ ^12.2.0         │
│ @angular/platform-browser-dynamic │ ^12.2.0         │
│ @angular/router                   │ ^12.2.0         │
│ @auth0/angular-jwt                │ ^5.0.2          │
│ @nativescript/angular             │ ^12.2.0         │
│ @nativescript/appversion          │ ^2.0.0          │
│ @nativescript/core                │ ~8.1.1          │
│ @nativescript/facebook            │ ^1.0.0-alpha.3  │
│ @nativescript/firebase-core       │ ^1.0.0-alpha.10 │
│ @nativescript/geolocation         │ ^7.2.2          │
│ @nativescript/iqkeyboardmanager   │ ^2.0.0          │
│ @nativescript/secure-storage      │ ^3.0.0          │
│ @nativescript/theme               │ ~3.0.1          │
│ @nstudio/nativescript-checkbox    │ ^2.0.4          │
│ @ticnat/nativescript-image-cache  │ ^1.0.5          │
│ @triniwiz/nativescript-toasty     │ ^4.1.3          │
│ moment                            │ ^2.29.1         │
│ nativescript-drop-down            │ ^6.0.0          │
│ nativescript-google-maps-sdk      │ ^3.0.2          │
│ nativescript-masked-text-field    │ ^4.0.3          │
│ nativescript-phone                │ ^3.0.2          │
│ nativescript-theme-core           │ ^2.0.24         │
│ rxjs                              │ ~7.3.0          │
│ zone.js                           │ ~0.11.4         │
└───────────────────────────────────┴─────────────────┘
Dev Dependencies:
┌───────────────────────┬─────────┐
│ Plugin                │ Version │
│ @angular/compiler-cli │ ^12.2.0 │
│ @nativescript/android │ 8.1.1   │
│ @nativescript/ios     │ 8.1.0   │
│ @nativescript/types   │ ~8.1.1  │
│ @nativescript/webpack │ ~5.0.0  │
│ @ngtools/webpack      │ ^12.2.0 │
│ typescript            │ ~4.3.5  │
└───────────────────────┴─────────┘

By advance, thanks you !

Spasfonx commented 3 years ago

It seems to be linked to this problem https://stackoverflow.com/questions/67765154/swiftui-facebook-sdk-app-id-not-found-add-a-string-value-with-your-app-id-for

abhayastudios commented 3 years ago

@triniwiz having the same issue while migrating from Eddy's plugin that was using FB SDK 11.2 to this one (so the Info.plist was already setup and working with the FB SDK). Even still I updated the Info.plist to match the latest instructions.

Spasfonx commented 3 years ago

Even with the latest instructions for the Info.plist the issue is still here. Have you some workaround ? I'm pretty stucked 😞

abhayastudios commented 2 years ago

@triniwiz just to see if this is related to the Facebook SDK, I tried to use the latest iOS SDK which is 12.1.0 which still gives the same error. Then I tried to downgrade to 11.2.1 and then I got what seems to be a somewhat more meaningful error message (if it is still relevant that is):

Error: As of v9.0, you must initialize the SDK prior to calling any methods or setting any properties. You can do this by calling FBSDKApplicationDelegate's application:didFinishLaunchingWithOptions: method. Learn more: https://developers.facebook.com/docs/ios/getting-startedIf no UIApplication is available you can use FBSDKApplicationDelegate's initializeSDK method.

So looking at line 45 there is a wrapper method for applicationDidFinishLaunchingWithOptions as part of the class FacebookAppDelegateImpl, but it is never called. If I call FacebookAppDelegateImpl.sharedInstance.applicationDidFinishLaunchingWithOptions(); after line 222 then it seems to start working...