Page 1 of 1

Example for the API?

Posted: 03 Mar 2012, 04:08
by mystarnee
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?

Re: Example for the API?

Posted: 03 Mar 2012, 04:10
by A51Integrated
Demo's will be updated shortly. We're actively working on it.

Re: Example for the API?

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

Re: Example for the API?

Posted: 04 Mar 2012, 02:29
by A51Integrated
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]];   
}

Re: Example for the API?

Posted: 09 Mar 2012, 05:47
by mystarnee
Can I do this:
- Login in the AppDelegate
- Listen ISFSEvents in another Class without relogin?

Re: Example for the API?

Posted: 10 Mar 2012, 03:53
by A51Integrated
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.