Example for the API?

Post here your questions about the Objective-C API for SFS2X

Moderators: Bax, Lapo, A51Integrated

Example for the API?

Postby mystarnee » 03 Mar 2012, 04:08

Hi,
I can't find any example for this API version. Why Smartfox don't make demo for it? Please let me know where I can find the example link?
mystarnee
 
Posts: 6
Joined: 03 Mar 2012, 04:03

Re: Example for the API?

Postby A51Integrated » 03 Mar 2012, 04:10

Demo's will be updated shortly. We're actively working on it.
A51 Integrated
http://a51integrated.com / +1 416-703-2300
User avatar
A51Integrated
 
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada

Re: Example for the API?

Postby mystarnee » 03 Mar 2012, 09:02

Thank you for your fast response. Would you please let me know how to implement ISFSEvents? and the -(void)onConnection:(SFSEvent *)evt;??
Best regards
mystarnee
 
Posts: 6
Joined: 03 Mar 2012, 04:03

Re: Example for the API?

Postby A51Integrated » 04 Mar 2012, 02:29

I your header file, implement ISFSEvents - something like
Code: Select all
#import <UIKit/UIKit.h>
#import <SFS2XAPI/SmartFox2XClient.h>

@interface ViewController : UIViewController <ISFSEvents>
{
   SmartFox2XClient *smartFox;
}

Then in your implementation, you can listen for the events
Code: Select all
-(void)viewDidLoad
{
   [super viewDidLoad];
   smartFox = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:YES delegate:self];
   [smartFox loadConfig:@"config.xml" connectOnSuccess:YES];
}
-(void)onConnection:(SFSEvent *)evt
{
   [smartFox send:[LoginRequest requestWithUserName:@"" password:@"" zoneName:nil params:nil]];   
}
A51 Integrated
http://a51integrated.com / +1 416-703-2300
User avatar
A51Integrated
 
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada

Re: Example for the API?

Postby mystarnee » 09 Mar 2012, 05:47

Can I do this:
- Login in the AppDelegate
- Listen ISFSEvents in another Class without relogin?
mystarnee
 
Posts: 6
Joined: 03 Mar 2012, 04:03

Re: Example for the API?

Postby A51Integrated » 10 Mar 2012, 03:53

Sure. Just make sure to implement ISFSEvents in your header file.

You can also access your SFS instance like:
Code: Select all
SmartFox2XClient *smartFox = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).smartFox;

assuming that smartFox is a property of the AppDelegate.
A51 Integrated
http://a51integrated.com / +1 416-703-2300
User avatar
A51Integrated
 
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada


Return to SFS2X iPhone / iPad / OSX API

Who is online

Users browsing this forum: No registered users and 3 guests