Facebook SDK iOS - how to set Application ID dynamically from code? - ios

I'm trying to set the Facebook's AppId from code, so I can choose to which app to connect to (between 2 apps, one of them is a test app).
Basically I'm looking for an equivalent for Android's SDK call:
FacebookSdk.setApplicationId(ACTIVE_APP_ID);
I'm aware of the deprecated iOS call:
[FBSettings setDefaultAppID:ACTIVE_APP_ID];
But can't seem to find alternative to it.
I'm using SDK ver 4.22.1. Thanks!

FacebookSDK v4.44.1 swift 5 - Set the Facebook App ID used by the SDK:
Settings.appID = "YOUR-FACEBOOK-APPLICATION-IDENTIFIER"
Settings.displayName = "YOUR-FACEBOOK-DISPLAY-NAME"
That's the way I have managed to set it programmatically and override the default settings at the info.plist file.

Maybe you can try :
[FBSDKSettings setAppID:ACTIVE_APP_ID];
(I am using version 4.29.0 of FBSDK).

Related

Check for warnings of deprecation and new methods

Recently I submitted my app on AppStore with a method setting badgecolor of tabbaritem.
[[[AppDelegate globalDelegate].tabBarController viewControllers] objectAtIndex:1].tabBarItem.badgeColor = kTabBarBadgeColor;
This badgeColor came in iOS 10 only and my app supported iOS 8 and above. I had no idea about it and the app got approved. Now, I have to resubmit my app with fixing this issue.
I want to know if there is a way to find out such cases where methods get deprecated or are visible in specific OS versions only.
By changing target of Xcode project you can see errors & warnings while building.
If you need more info,
You can visible all API changes like Added,Modified & Deprecated variants in Apple documentation
it will give you searching options for both Swift & Objective C
Searching UITabBarItem Instance Property badgeColor. it gives API changes are none.Supporting SDK's version
SDKs
iOS 10.0+
tvOS 10.0+
Searching finishedSelectedImage instance method of UITabBarItem.
SDK
iOS 5.0–7.0 Deprecated
Deprecated Use selectedImage with UIImageRenderingModeAlwaysOriginal
instead.

To use two Facebook app ids on the same app for testing

In order to test Facebook Events without modify the production data I need to use a second Facebook App Id inside of my iOS app. I want to do that automatically my Continuous Integration environment.
Release Scheme -> Will have production Facebook app id.
Debug Scheme -> Will have debug Facebook app id.
Do you use a pre-building script to modify the info.plist file? Do you know a better way to solve this problem?
The App ID in the plist is a convenient way to set it up but the Facebook SDK allows you to set it inside the app as well.
Newer SDK:
[FBSDKSettings setAppID:#"xxx"];
Older SDKs:
[FBSettings setDefaultAppID:#"xxxx"]
That should allow you to switch between app ids when needed.
I use compiler constants testing:
#if defined(DEBUG)
// Older Facebook SDK:
// [FBSettings setDefaultAppID:#"debugID"];
[FBSDKSettings setAppID:#"debugID"];
#else
// Older Facebook SDK:
// [FBSettings setDefaultAppID:#"productionID"];
[FBSDKSettings setAppID:#"productionID"];
#endif

Paypal Integration swift iOS

Hi I'm new to using Paypal, I've started using paypal SDK but I can't find a way of turning the code below so my swift app delegate can pick it up can anyone inform me of how I may be able to change the code below and change it so my swift file can pick it up ?
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : #"YOUR_CLIENT_ID_FOR_PRODUCTION",PayPalEnvironmentSandbox : #"YOUR_CLIENT_ID_FOR_SANDBOX"}];
Try this one:
PayPalMobile.initializeWithClientIdsForEnvironments([PayPalEnvironmentProduction: "YOUR_CLIENT_ID_FOR_PRODUCTION", PayPalEnvironmentSandbox: "YOUR_CLIENT_ID_FOR_SANDBOX"])

Symbol not found: ABAddressBookCreateWithOptions

I've been working on an iPhone app which can brings the contacts from iPhone device to app , i've read about Addressbook privacy control , that is ios6 need ABAddressBookCreateWithOptions , and which is working good in iOS6 but if i'm running this app in iOS5 and below i'm getting error like this :
objective c Symbol not found: ABAddressBookCreateWithOptions , please provide me the solution to run this app in iOS6 and below versions ... thanks ...
A cleaner approach is to actually check for the symbol at runtime:
-(BOOL)isABAddressBookCreateWithOptionsAvailable {
return &ABAddressBookCreateWithOptions != NULL;
}
Take a look at this answer for a full iOS 5/6 compatible approach to reading contacts from the address book.
You can't use it in iOS5 because the docs say Available in iOS 6.0 and later. In iOS 5 use the ABAddressBookCreate version (which is deprecated in iOS 6).

Reminder API in iOS 6.0

Strange bug in iOS 6.0 sdk. Apple promised to deliver full reminder support via api, to allow thirdparty applications to read and write reminders on behalf of user. There is new methods in SDK to init storekit for use with reminders.
But seems like main method to make it possible - just not present. Both GM version of XCode 4.5 and simulator/ios-6 upgraded device shows that EKEventStore:initWithAccessToEntityTypes is not present in SDK and attempt to call it on device/simulator crashing application with
Error invoking method 'EKRemsIsGranted' on 'CEKtils' because
-[EKEventStore initWithAccessToEntityTypes:]: unrecognized selector sent to instance 0x13a59140
Interesting that this method is also mentioned and described in MacOs 10.8
but in iOS sdk it is mentioned but NOT described
Seems like apple devs forgot to "enable" it on iOS. is it possible at all or I missing something?
There's a description of the event (and some other useful information) here. You might also double-check that your UIEventKit framework is properly linked and up to date.

Resources