I am a Unity game developer and know very little about app side code, so forgive me if I'm doing something stupid.
I'm trying to set up Firebase to work in my Unity iOS app. I'm in the very first setup, trying to get the SDK working.
So Firebase has you do a couple steps, and then they want you to do some initialization in your App Delegate. They want you to add two lines, an import and a configure. This is the code from their setup section.
#import UIKit;
#import Firebase;
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
return YES;
}
So Unity doesn't actually use a traditional AppDelegate. I went sleuthing and found this guy's work. He basically shows how to use a standard Unity Plugin to override the app delegate. So I put the following code in my Plugins folder.
#import "UnityAppController.h"
#import Firebase;
#interface OverrideAppDelegate : UnityAppController
#end
IMPL_APP_CONTROLLER_SUBCLASS(OverrideAppDelegate)
#implementation OverrideAppDelegate
-(BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) options
{
NSLog(#"[OverrideAppDelegate application:%# didFinishLaunchingWithOptions:%#]", application, options);
[FIRApp configure];
return [super application:application didFinishLaunchingWithOptions:options];
}
#end
Now. I'm pretty sure the Plugin is working because I can find it in my XCode project, and when I was screwing around with it and had two instances of [FIRApp configure]; it actually crashed with an error basically saying, "don't configure twice". But Firebase has not received anything from my app. They have a little prompt that says, "Checking if the app has communicated with our servers. You may need to uninstall and reinstall your app." I've uninstalled, reinstalled, tried their whole installation process again, and still nothing.
Any thoughts?? Thanks ahead of time.
If you're developing an app in Unity you can use the Firebase for Unity plugin rather than implementing your own iOS solution. Try adding Analytics to your app with this guide.
Related
I am building a plugin to integrate an external framework to an Cordova, following the documentation, I need to include a new delegate to AppDelegate.h of my app.
If was developing a native application, i just need to import the file and include the delegate on it.
#import <MySpinServerSDK/MySpinServerSDK.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate, MySpinServerSDKDelegate>
How can I add a extra delegate to a Cordova App for iOS using the plugin structure?
I did all the preparation in a plugin (external frameworks an plist configuration) but not sure if its possible to create this kind of integration using cordova plugins.
You can reference these Cordova Plugins as examples: App-Event or Deep Links
Note how the App Event developer named the new files with a plus sign: AppDelegate+APPAppEvent.h and AppDelegate+APPAppEvent.m in his Cordova plugin. In the header file, the developer used a category "APPAppEvent" while declaring his new class as an AppDelegate:
#interface AppDelegate (APPAppEvent)
#end
The Deep Links developer did the same:
#interface AppDelegate (CULPlugin)
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler;
#end
I am trying to add Firebase to my Codename One iOS app.
I've read up on how to add Native Interfaces in Codename One and have successfully added the CocoaPods for Firebase as well. However, being unfamiliar with Objective-C and iOS in general (I've never worked on an iOS app outside of the Codename One framework), I'm not sure how to integrate these instructions from the Firebase website into my interface:
#import UIKit;
#import Firebase;
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
return YES;
}
As well as the instructions here: https://firebase.google.com/docs/analytics/ios/start?authuser=0,
specifically:
Import the Firebase module in your UIApplicationDelegate subclass:
OBJECTIVE-C
#import Firebase;
Configure a FirebaseApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:
OBJECTIVE-C
// Use Firebase library to configure APIs
[FIRApp configure];
I added the .plist file to my native -> ios folder.
EDIT: I want to use the following Firebase features: analytics and crash reporting to start with, eventually notifications.
Can someone advise how this would be done?
Thanks!
Add the build hints:
ios.afterFinishLaunching=[FIRApp configure];
ios.glAppDelegateHeader=#import <Firebase/Firebase.h>
The rest of the things you can just invoke in the native interface code. Notice the tip to wrap the code in async blocks https://www.codenameone.com/blog/tip-use-native-edt.html
trying to install Fabric Crashlytics on my Cordova project
I followed all the steps and installing all rquired steps with building the project , but at the final step i got stuck there without any action
here is my AppDelegate.h
#import "AppDelegate.h"
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Fabric with:#[[Crashlytics class]]];
return YES;
}
#end
after I build the project it's stuck there without any action
^^ this screen waits for 1 minute then it's cahnged to
I checked the info.plist and seems good without any problem
Mike from Fabric here. We don't have support for Cordova based projects. We need to see a build and run of your app with Fabric enabled. I'd recommend a clean, build and run with Fabric enabled on a device to see if that helps.
I am trying to use the Intercom iOS SDK in a Swift app that I am building. However, all their documentation is written in Objective-C. As I am just starting out I am not quite sure how to implement Intercom in my application.
I've added "pod 'Intercom'" to my Podfile and added the import statement to my bridging header.
The next step in setting up intercom in an iOS app is initializing it in my applications AppDelegate with the following code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize Intercom
[Intercom setApiKey:#"<#ios_sdk-...#>" forAppId:#"<#your-app-id#>"];
}
And then using objective-c code in my swift view-controller like so:
- (void)successfulLogin {
...
// Registering with Intercom is easy. For best results, use a unique user_id if you have one.
[Intercom registerUserWithUserId:#"<#123456#>"];
}
How do I implement Objective-c code like this in my swift project?
I've searched around, as well as contacted Intercom's support, but am yet to find an answer.
Many thanks!
[Intercom setApiKey:#"<#ios_sdk-...#>" forAppId:#"<#your-app-id#>"];
becomes
Intercom.setApiKey("<#ios_sdk-...#>", forAppId:"<#your-app-id#>")
and
[Intercom registerUserWithUserId:#"<#123456#>"];
becomes
Intercom.registerUserWithUserId("<#123456#>")
I would suggest to look over Swift tutorials to see the syntax and learn how to migrate Objective-C code to Swift code properly.
I've followed the instructions on this page for my Xcode project (ios app): https://developers.facebook.com/docs/ios/getting-started/
installed the Facebook SDK for iOS
obtained Facebook App ID
configured Xcode project
archived Xcode proj, submitted to Apple, approved and live
And I've created and run ads for app installs however how do I know how many people have installed my app as a result of the ads? There is nothing showing top left of the ads page....just zero???? Nothing showing in my Facebook Developer account.
I've clearly missed a pretty obvious step...can someone please shed some light?
You're probably not calling [FBAppEvents activateApp] on applicationDidBecomeActive:.
Check also if you have a FacebookAppID key on your target's Info.plist.
You AppDelegate needs to look like this:
#import "AppDelegate.h"
#import <FacebookSDK.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// stuff
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBAppEvents activateApp];
}
#end