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.
Related
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.
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
I tried asking this question over at apple.stackexchange.com, but it was marked as off-topic for that board, so I'm hoping here is more appropriate:
I am following 2 iOS tutorials (Big Nerd Ranch and another one), both of which explicitly state they're using XCode 5 and iOS 7. When referencing the method 'application:didFinishLaunchingWithOptions:' of AppDelegate.m, both also show pre-existing code which initializes 'self.window' and, further down in the method, calls [self.window makeKeyAndVisible]. For example, the following image was taken from this tutorial:
I am using XCode 6.4 with iOS 8.4. I've tried creating several types of applications, including single-view apps, master-detail apps, and page-based apps. In each of these apps, the default template for the 'application:didFinishLaunchingWithOptions:' method appears as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
I'm wondering why the code seems to be missing from my Xcode 7 default templates. It seems like something most devs would want included by default, since now they'll likely have to write it manually for most apps. Therefore, if Apple did indeed remove it, I'm curious what the motivation for this could have been.
This is because by default new projects are configured to use storyboards, which do not require the AppDelegate to setup the window.
HI i'm trying to develop a function that uses APPLOVIN to show adds. i don't see any errors messages an nothing, The game starts normally but no add is shown
I imported the library
I think i'm doing all the correct steps:
1)Importing all libraries into the project
2)setting the KEY that APPLOVIN provides
3) set the -OgjC configuration key
4)Do all imports into the delegate class
5) load library
[ALSdk initializeSdk];
and
[ALInterstitialAd showOver:[[UIApplication sharedApplication] keyWindow]];
I did all the steps posted here: https://www.applovin.com/integration#iosIntegration
Is it any step that i need to perform in order to show an add?
I looked into some other posts and they use an banner object, but don't know how to integrate in COCOS2d. can someone provide some guidance on this please?
Thanks in Advance!!
Applovin Integration Steps :
Initialize
-(void)applicationDidBecomeActive:(UIApplication *)application
{
[ALSdk initializeSdk];
}
Show Ads :
-(void)showAplovinAds
{
[ALInterstitialAd showOver:[[UIApplication sharedApplication] keyWindow]];
}
Add SDK Key in info.plist
I have successfully got pixate 2.0.1 working with XCode 5 on a ios 7 project. Its really awesome actually! And it would be even way more awesome with Real Time CSS. This is basically where the iPhone/iPad simulator will update live while the css file is edited and saved. Now thats just cherry all the way. But unfortunately I'm not yet able to get it working. I followed the directions that Paul Colton gave here: http://youtu.be/rjNrNIyEL_c. But it is for version 1 of Pixate and uses the now outdated PXEngine syntax.
Anybody know how to get this working in version 2.0.1 of Pixate?
Assuming you have followed the latest instructions for installing version 2.x found here: http://www.pixate.com/docs/framework/ios/latest/getting-started/
Then make sure you have the following in your AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Initalize Pixate
self.window.styleMode = PXStylingNormal;
//Dynamically modify the Pixate stylesheet while the Simulator is running
#ifdef DEBUG
[Pixate styleSheetFromFilePath:#"/Users/YourHomeFolder/Path/To/default.css" withOrigin:PXStylesheetOriginApplication];
Pixate.currentApplicationStylesheet.monitorChanges = YES;
#endif
}
Hopefully that helps.