App crash on using Fabric and TwitterKit - ios

I've got this line of code on my application didFinishLaunchingWithOptions delegate method and it causes a crash saying:
'[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'
Anyone can help me with this one?
Here's the code that causing the crash:
[[Twitter sharedInstance] startWithConsumerKey:#"consumer_key" consumerSecret:#"secret_key"];
[Fabric with:#[[Twitter sharedInstance]]];

Alex from Fabric here. To use different Twitter API keys or API keys generated on apps.twitter.com, you're declaring it correctly in your code above. It sounds like you may not have fully onboarded your app through the Fabric app, and required entries, like the Fabric APIKey, are missing from your info.plist.
Some more info on the Fabric Mac App and info.plist:
When you onboard an kit through the Mac App, a Fabric Dictionary entry is injected into your info.plist. Under the Fabric parent, there will be two children entries: APIKey and Kits.
Your Fabric API key, if it's not injected for some reason (it should be added automatically if you're using the Fabric app) or you want to manually change it, can be found by visiting https://fabric.io/settings/organizations, clicking your organization and clicking "API Key" below the organization title.
The Kits array contains an Item X for each Fabric kit you've included. If you've included Twitter Kit, the automatically provisioned consumerKey and consumerSecret are listed under KitInfo.

I followed the steps as described above but still was getting this error
uncaught exception 'TWTRInvalidInitializationException', reason:
'Attempted to call TwitterKit methods before calling the requisite
start methods; you must call +[Fabric with:#[Twitter class]] before
using the methods on TwitterKit
As i am using multiple kits i tried to initialize on different calls as follows
[Fabric with:#[[Crashlytics class]]];
[Fabric with:#[[Twitter class]]];
As per Fabric documentation for + (instancetype)with:(NSArray *)kitClasses;
Only the first call to this method is honored. Subsequent calls are
no-ops.
So only Crashlytics was initializing and Twitter got ignored.
Solution was to initialize as follows;
[Fabric with:#[[Crashlytics class], [Twitter class]]];

Related

iOS, Firebase - Firebase causing crash - How to unconfigure app so that I can use database?

I configured my app using
FirebaseApp.configure();
In my Appdelegate and launched the app.
I then needed to add database functionality so I removed the above code (because it crashes and tells me the app is already configured) and added:
AppDelegate.ref = Database.database().reference()
But then I get this error:
must call `[FIRApp configure]` (`FirebaseApp.configure()` in Swift) before using Firebase Database.'
So, I am now stuck because if I add the configure() back my app just crashes and the error tells me the app is already configured.
Do I have to reconfigure? If so, how do I go about doing that as there is nothing in the documentation on this?
As suggested by Francesco, I redownloaded the configuration file. This fixed the issue.

What happens under the hood when Fabric initializes it's modules (Crashlytics / Twitter)?

I want to integrate Crashlytics (3.9.3) into an internal library but I am faced with the following situation:
One of our internal libraries we are using is already using TwitterKit(2.2.0) with Fabric (1.6.7). This means that it is already doing it's initialization using this method:
[Fabric with:#[[Twitter class]]]
Now, this means that we can't initialize Crashlytics the same way because Twitter initialization would not be taken into consideration, since "Fabric with" method is going to be ignored on subsequent calls.
I know that the best method would be to call fabric in the main app like this:
[Fabric with:#[[Twitter class], [Crashlytics class]]];
but in our case it's desired to not impact the applications that are already using the the old lib, and keep compatibility.
Now, would it be safe to replace the current Fabric Twitter initialization and add the Crashlytics initialization with legacy method like this?
// replace original with this with info taken from Info.plist
[[Twitter sharedInstance] startWithConsumerKey:consumerKey
consumerSecret:consumerSecret];
// in another place
[Crashlytics startWithAPIKey:#"a1b2c3..."];
Is fabric doing any other stuff under the hood except the above or is it just parsing the info.plist for the keys and initializing the frameworks? Should we worry about any issues? Tested it and seems to be working ok.
Also, I am aware that Twitter is no longer part of the newest Fabric, but we are using some older versions here.
What I've also noticed is that if we keep the "Fabric with Twitter" part unchanged and initialize Crashlytics with "startWithAPIKey" method, Twitter will not be initialized ok.
Mike from Fabric here. Your approach may work, but could cause many issues as we haven't tested any of the most recent versions of Fabric with that version of Twitter so you would be at risk of seeing strange SDK behavior.

GCM : Configuring subspecs failed # CloudMessaging

I am trying to integrate Google Cloud Messaging in my iOS application. I have followed every instruction provided in this link.
I have also integrated Google sign-in and it works fine.
The problem is I am getting assertion failure in the below code.
NSError* configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, #"Error configuring Google services: %#", configureError);
Which is used to configure subspecs for cloud messaging.
This code above is in didFinishLaunchingWithOptions method in AppDelegate.m file.
The error generated is:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error configuring Google services: Error Domain=com.google.greenhouse Code=-104 "Unable to correctly configure subspec CloudMessaging" UserInfo={NSLocalizedDescription=Unable to correctly configure subspec CloudMessaging, NSLocalizedFailureReason=GCM Sender ID must not be nil or empty.
Now I don't understand the meaning of this error. Yes, it clearly states that sender ID must not be nil. But from where it gets null ID.
I have tested this in simulator. I don't know if that affects or not.
If I comment this code and run in real device I also get the registration token but I don't receive any notification from my server. Server side code is tested and works fine for android.
Finally I solved the problem. First of all thank you all for quick reply.
What I did is explained in the following steps.
Get GCMExample project. Which I downloaded from Github because pod try google does not list GCMExample project.
Generate GoogleServices-Info.plist file from here
Compare plist files of GCMExample and MyProject.
Here I got the difference in it. In My project GCM was disabled and there was no Sender ID in it. I don't know how the hell did that happened.
So I manually set the GCM service enabled and added sender ID of my app that I previously created.
That is how I solved my problem.
Check Below Link for certificate
cloud-messaging_ios_certs
Make sure you are following below steps correctly
Create your App ID with Push Notifications ON.
Create your SSL Certificate.
Download and run it in order to be added to the Provisioning Profile.
To make sure that your provisioning profile has this certificate go to Xcode -> Preferences -> Account -> Your Apple ID -> Your Team -> View Details -> Download All.

Fabric Crashlytics api key is null despite startWithApiKey

On my iOS project, I updated Crashlytics from the version 2.x to the version 3.1.0.
I added a script in the Build Phases on xCode:
if [ ${MY_VAR} == 1 ]; then
./Pods/Fabric/Fabric.framework/run <api key> <build secret>
else
./Pods/Fabric/Fabric.framework/run <another api key> <another build secret>
Then, in my AppDelegate I added CrashlyticsKit to Fabric:
#if MY_VAR
[Crashlytics startWithAPIKey:#"api_key"];
#else
[Crashlytics startWithAPIKey:#"another_api_key"];
#endif
[Fabric with:#[CrashlyticsKit]];
NSLog(#"Crashlytics api key: %#", CrashlyticsKit.apiKey);
I tried to print the apiKey to be sure that everything work well, but unfortunately, the apiKey attribute is null.
Any suggestion?
Alex from Fabric here. We looked into this because there are a couple of strange things going on here! First off, the code in your AppDelegate should work, but you don't need both:
[Crashlytics startWithAPIKey...];
and
[Fabric with...];
You can remove one of them. [Crashlytics startWithAPIKey] is considered legacy but it will still to work.
It looks like you discovered a bug in our Crashlytics header file. In our header the property is apiKey but in the code it's APIKey. You can access the value by calling CrashlyticsKit.APIKey if you want to confirm that your logic is working, but we're going to fix this so that it's CrashlyticsKit.apiKey.
Are you using the official CocoaPod that we released?

App is crashing while using Google Sign in for iOS with AssertionFailure

I tried to implement Google Sign in for iOS according to the docs - iOS implentation. But the app is crashing with an error while calling
[[GGLContext sharedInstance] configureWithError: &configureError];
in my App Delegate's application:didFinishLaunchingWithOptions method.
Error :-
Assertion failure in void validateGoogleSignInWithURLSchemes(NSArray *__strong)(), googlemac/iPhone/Greenhouse/Source/GGLURLSchemeUtil.m:39
I have added GoogleService-Info.plist to the target resources and also added URL Types for REVERSED_CLIENT_ID and Bundle Identifier as explained in the docs and also referenced here.
Is there something I am missing or what should I do to fix the same?
It was due to a simple spelling mistake. I had my Bundle Identifier wrong in the URL scheme while adding URL Types.
Please suggest if it's better to delete this question. I will delete the same.

Resources