How to use Socialize in your iPhone/iPad native application?


Hi,

I have integrate Socialize in one of my sample code and believe me it’s amazing.it’s far better than any other sharing media.just visit this web site initially.http://www.getsocialize.com/.

It includes Email,Facebook and Twitter.I have Integrated Email and Twitter and working on Facebook as well.I am going to Explain you how to integrate it in your application.

Step 1: Click Here

Step 2: Choose 1 st option  Register and get your API keys.Once you have your API Key’s with you then follow step 3.

Step 3: When you click on DownLoad SDK for iOS you will get Framework for Integration.

Step 4: Add Socialize framework to your Application with Copy option selected as shown in the image.

step 5:Add Required Framework as shown below.

CoreLocation.framework,MapKit.framework,MessageUI.framework,QuartzCore.framework,CoreGraphics.framework

step 6: Set other Linker Flag as shown below.

step 7: Import Header and Set up your Socialize Keys like this.

//import the socialize header
#import <Socialize/Socialize.h>

#pragma mark
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
    // set the socialize api key and secret, register your app here: http://www.getsocialize.com/apps/
    [Socialize storeConsumerKey:@"SOCIALIZE_CONSUMER_KEY"];
    [Socialize storeConsumerSecret:@"SOCIALIZE_CONSUMER_SECRET"];

    //your application specific code

    return YES;
}

Step 8: Include Socialize in your App!

// Header file

// Store the action bar in a property on your view controller

#import <Socialize/Socialize.h>

@interface CreateActionBarViewController : UIViewController
@property (nonatomic, retain) SocializeActionBar *actionBar;
@end
// Implementation file

// Instantiate the action bar in your view controller

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (self.actionBar == nil) {
        self.actionBar = [SocializeActionBar actionBarWithKey:@"http://www.example.com/object/1234" name:@"Something" presentModalInController:self];
        [self.view addSubview:self.actionBar.view];
    }
}

Now your App is ready to display Socialize bar.Here I am giving you the Sample code with Twitter integration and update it once it get completed with Facebook as well.

How to add Email and Message in your native application?


Hi,

See new sample code “MessageComposer” which includes both Mail and Messages features.

This application shows how to target older OS versions while building with newly released APIs. It also illustrates how to use the MessageUI framework to edit and send email messages from within your application.

Tap the “Compose Mail” button to display an email composition interface if your device is running iPhone OS 3.0 or launch the Mail application, otherwise.

Step 1:

Add MessageUI.framework to your Application.Add this Header file to the .h file and Provide delegate of it as shown below.

#import <MessageUI/MessageUI.h>

#import <MessageUI/MFMailComposeViewController.h>

@interface MailComposerViewController : UIViewController <MFMailComposeViewControllerDelegate>

{

IBOutlet UILabel *message;

}

@property (nonatomic, retain) IBOutlet UILabel *message;

-(IBAction)showPicker:(id)sender;

-(void)displayComposerSheet;

-(void)launchMailAppOnDevice;

 

Step 2:Now write the code for mail.

-(IBAction)showPicker:(id)sender

{

// This sample can run on devices running iPhone OS 2.0 or later

// The MFMailComposeViewController class is only available in iPhone OS 3.0 or later.

// So, we must verify the existence of the above class and provide a workaround for devices running

// earlier versions of the iPhone OS.

// We display an email composition interface if MFMailComposeViewController exists and the device can send emails.

// We launch the Mail application on the device, otherwise.

 

Class mailClass = (NSClassFromString(@”MFMailComposeViewController”));

if (mailClass != nil)

{

// We must always check whether the current device is configured for sending emails

if ([mailClass canSendMail])

{

[self displayComposerSheet];

}

else

{

[self launchMailAppOnDevice];

}

}

else

{

[self launchMailAppOnDevice];

}

}

 

 

#pragma mark –

#pragma mark Compose Mail

 

// Displays an email composition interface inside the application. Populates all the Mail fields.

-(void)displayComposerSheet

{

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;

 

[picker setSubject:@”Hello from Ankit Vyas!”];

// Set up recipients

NSArray *toRecipients = [NSArray arrayWithObject:@”first@example.com”];

NSArray *ccRecipients = [NSArray arrayWithObjects:@”second@example.com”, @”third@example.com”, nil];

NSArray *bccRecipients = [NSArray arrayWithObject:@”fourth@example.com”];

 

[picker setToRecipients:toRecipients];

[picker setCcRecipients:ccRecipients];

[picker setBccRecipients:bccRecipients];

 

// Attach an image to the email

NSString *path = [[NSBundle mainBundle] pathForResource:@”rainy” ofType:@”png”];

NSData *myData = [NSData dataWithContentsOfFile:path];

[picker addAttachmentData:myData mimeType:@”image/png” fileName:@”rainy”];

 

// Fill out the email body text

NSString *emailBody = @”It is raining in sunny California!”;

[picker setMessageBody:emailBody isHTML:NO];

 

[self presentModalViewController:picker animated:YES];

[picker release];

}

// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.

– (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error

{

message.hidden = NO;

// Notifies users about errors associated with the interface

switch (result)

{

case MFMailComposeResultCancelled:

message.text = @”Result: canceled”;

break;

case MFMailComposeResultSaved:

message.text = @”Result: saved”;

break;

case MFMailComposeResultSent:

message.text = @”Result: sent”;

break;

case MFMailComposeResultFailed:

message.text = @”Result: failed”;

break;

default:

message.text = @”Result: not sent”;

break;

}

[self dismissModalViewControllerAnimated:YES];

}

#pragma mark –

#pragma mark Workaround

// Launches the Mail application on the device.

-(void)launchMailAppOnDevice

{

NSString *recipients = @”mailto:first@example.com?cc=second@example.com,third@example.com&subject=Hello from California!”;

NSString *body = @”&body=It is raining in sunny California!”;

 

NSString *email = [NSString stringWithFormat:@”%@%@”, recipients, body];

email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];

}

#pragma mark –

#pragma mark Unload views

 

– (void)viewDidUnload

{

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

self.message = nil;

}

#pragma mark –

#pragma mark Memory management

– (void)dealloc

{

[message release];

[super dealloc];

}

for more detail Grab the Code From Here