update status in linkedin through iphone app - ios5

This is my code so far:
-(IBAction)postToLinkedin{
rdEngine = [RDLinkedInEngine engineWithConsumerKey:LI_kOAuthConsumerKey consumerSecret:LI_kOAuthConsumerSecret delegate:self] ;
RDLinkedInAuthorizationController* controller = [RDLinkedInAuthorizationController authorizationControllerWithEngine:rdEngine delegate:self];
if( controller) {
[self presentModalViewController:controller animated:YES];
}
else
{
NSLog(#"alreadyy authenticated");
}
}
-(void)linkedInEngineAccessToken:(RDLinkedInEngine *)engine setAccessToken:(OAToken *)token {
NSLog(#"1111111");
[token storeInUserDefaultsWithServiceProviderName:#"LinkedIn" prefix:#"Demo"];
}
- (void)linkedInEngineAccessToken:(RDLinkedInEngine *)engine removeAccessToken:(OAToken *)token {
[token removeAccessTokenUsingServiceProviderName:#"LinkedIn" prefix:#"Demo"];
}
- (OAToken *)linkedInEngineAccessToken:(RDLinkedInEngine *)engine {
return [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:#"LinkedIn" prefix:#"Demo"] ;
NSLog(#"3333");
}
- (void)linkedInEngine:(RDLinkedInEngine *)engine requestSucceeded:(RDLinkedInConnectionID *)identifier withResults:(id)results {
NSLog(#"++ LinkedIn engine reports success for connection %#\n%#", identifier, results);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Success" message:#"Successfully Tweeted" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
- (void)linkedInEngine:(RDLinkedInEngine *)engine requestFailed:(RDLinkedInConnectionID *)identifier withError:(NSError *)error {
NSLog(#"++ LinkedIn engine reports failure for connection %#\n%#", identifier, [error localizedDescription]);
}
//#pragma mark -
//#pragma mark RDLinkedInAuthorizationControllerDelegate
- (void)linkedInAuthorizationControllerSucceeded:(RDLinkedInAuthorizationController *)controller {
NSLog(#"Authentication succeeded.");
NSLog(#"Fetching current user's profile on connection %#", [controller.engine profileForCurrentUser]);
[rdEngine updateStatus:#"hello"];
}
- (void)linkedInAuthorizationControllerFailed:(RDLinkedInAuthorizationController *)controller {
NSLog(#"Authentication failed!");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Error occurred while updating Linkedin status." delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
- (void)linkedInAuthorizationControllerCanceled:(RDLinkedInAuthorizationController *)controller {
NSLog(#"Authentication was cancelled.");
}
The code is not working because the status is not getting updated.
could you please tell me where I am going wrong?

Why are you showing the authorization controller in postToLinkedIn?
You might want to take a look at the Share API here https://developer.linkedin.com/documents/share-api

Related

MFMessageController crash sometimes

I have the concept of sharing to contacts in my App and used MFMessageComposeViewController.
-(IBAction)btnAddClicked:(id)sender {
#try {
selections = [[NSMutableArray alloc] init];
for(NSIndexPath *indexPath in arSelectedRows) {
NSMutableDictionary *searchable = [[NSMutableDictionary alloc
]init];
[searchable setObject:[[contactsArray objectAtIndex:indexPath.row]objectForKey:#"Phone"]forKey:#"Phone"];
[selections addObject:searchable];
}
if([selections count]>0)
{
NSString *temp1=#"";
for(int i=0;i<[selections count];i++)
{
toRecepients=[[selections objectAtIndex:i]objectForKey:#"Phone"];
temp1=[temp1 stringByAppendingString:toRecepients];
temp1=[temp1 stringByAppendingString:#","];
}
temp1 = [temp1 substringToIndex:[temp1 length]-1];
if(![MFMessageComposeViewController canSendText]) {
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Your device doesn't support SMS!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}
NSArray *recipents = [temp1 componentsSeparatedByString:#","];
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
messageController.navigationBar.topItem.leftBarButtonItem.title = #"Cancel";
[messageController setRecipients:recipents];
[messageController setBody:self.message];
[self presentModalViewController:messageController animated:YES];
}
else{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Select the contacts you would like to share to" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}
}
#catch (NSException *exception) {
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{
ErrorView *errorView=[[ErrorView alloc]initWithNibName:#"ErrorView" bundle:nil];
if([[[UIDevice currentDevice]systemVersion]floatValue]<5.0)
{
[self presentModalViewController:errorView animated:YES];
}
else
{
[self presentViewController:errorView animated:YES completion:nil];
}
[errorView release];
}
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) {
ErrorView *errorView=[[ErrorView alloc]initWithNibName:#"ErrorView~iPad" bundle:nil];
if([[[UIDevice currentDevice]systemVersion]floatValue]<5.0)
{
[self presentModalViewController:errorView animated:YES];
}
else
{
[self presentViewController:errorView animated:YES completion:nil];
}
[errorView release];
}
} }
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result {
switch (result) {
case MessageComposeResultCancelled:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Failed to send SMS!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultFailed:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Failed to send SMS!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultSent:
{
NSString *messa=[NSString stringWithFormat:#"Shared to %lu contact(s)",(unsigned long)[selections count]];
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:#"Succesful" message:messa delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
default:
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
This is the code Im using, which crashes sometimes and displays the error
Assertion failed: (result == KERN_SUCCESS), function +[XPCMachSendRight wrapSendRight:], file /SourceCache/XPCObjects/XPCObjects-46/XPCMachSendRight.m, line 27.
I have put breakpoint to debug, but xcode doesn't showup where the error is produced.
Any ideas/ suggestions would be appreciable..
Enable zombie Objects to find out the line of actual crash.
You can enable Zombie by following steps:
1.Select you project scheme and chose edit scheme.
2.A window will appear, now select diagnostics.
3.Select check mark for enable Zombie objects.
Now run your project.

iOS Core Bluetooth Not asking for Pair

In My recent project, I need to communicate a Hardware (Bluetooth Low energy).I have implement all the delegate methods code. I am able to Connect hardware and device, But I am not getting pairing alert (Attached screen shot). Why not it is asking for pairing? Thank you.
#import "BTWCentralConnectionManager.h"
#implementation BTWCentralConnectionManager
#synthesize cbcManager;
#synthesize discoveredPeripheral;
#synthesize findMeServiceCharacteristic;
#synthesize findMeService;
#synthesize delegate=_delegate;
static NSString *kFindMeServiceUUID=#"1802";
static NSString *kFindMeCharacteristicUUID=#"2A06";
static BTWCentralConnectionManager* connectionManager = nil;
+(BTWCentralConnectionManager *)sharedConnectionManager{
#synchronized(self)
{
if (!connectionManager){
connectionManager=[[self alloc] init];
}
return connectionManager;
}
return nil;
}
-(void)findMe {
Byte code=0x02;
if(self.discoveredPeripheral){
[self.discoveredPeripheral writeValue:[NSData dataWithBytes:&code length:1] forCharacteristic:self.findMeServiceCharacteristic type:CBCharacteristicWriteWithoutResponse];
}else{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:#"Invalid Charactersitcs" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
}
-(void)searchForDevices{
self.cbcManager=[[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
-(void)connect {
NSDictionary* connectOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey];
[self.cbcManager connectPeripheral:self.discoveredPeripheral options:connectOptions];
}
-(void)disconnect{
[self cleanup];
}
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
switch (central.state) {
case CBCentralManagerStatePoweredOn:{
[self.cbcManager scanForPeripheralsWithServices:#[ [CBUUID UUIDWithString:kFindMeServiceUUID] ] options:#{CBCentralManagerScanOptionAllowDuplicatesKey : #NO }];
}
break;
// Scans for any peripheral
default:{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:#"Cental Manager did change state" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
break;
}
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
// Stops scanning for peripheral
[self.cbcManager stopScan];
if (self.discoveredPeripheral != peripheral) {
self.discoveredPeripheral = peripheral;
[self.delegate didDeviceDiscoverd:self.discoveredPeripheral.name];
}
}
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error
{
[self.delegate didDeviceConnectionFailed:error];
[self cleanup];
}
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
{
[self.delegate didDeviceConnected];
[self.discoveredPeripheral setDelegate:self];
[self.discoveredPeripheral discoverServices:#[[CBUUID UUIDWithString:kFindMeServiceUUID]]];
}
- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverServices:(NSError *)error {
if (error) {
NSString *strMsg=[NSString stringWithFormat:#"didDiscoverServices: %#", error];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg
delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
[self cleanup];
return;
}
for (CBService *service in aPeripheral.services) {
if ([service.UUID isEqual:[CBUUID UUIDWithString:kFindMeServiceUUID]]) {
self.findMeService=service;
[self.discoveredPeripheral discoverCharacteristics:#[[CBUUID UUIDWithString:kFindMeCharacteristicUUID]] forService:self.findMeService];
}
}
}
- (void) peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
if(error){
NSString *strMsg=[NSString stringWithFormat:#"didDiscoverCharacteristicsForService: %#", error];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
for(CBCharacteristic *character in [service characteristics])
{
if([[service UUID] isEqual:[CBUUID UUIDWithString:kFindMeServiceUUID]] &&
[[character UUID] isEqual:[CBUUID UUIDWithString:kFindMeCharacteristicUUID]])
{
NSString *strMsg=[NSString stringWithFormat:#"didDiscoverCharacteristicsForService: %#", character];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
self.findMeServiceCharacteristic = character;
}
}
}
- (void) peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
NSString *strMsg=[NSString stringWithFormat:#"Did update value for characteristic %#, new value: %#, error: %#", characteristic, [characteristic value], error];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
if (error) {
NSLog(#"Error changing notification state: %#", error.localizedDescription);
}
// Exits if it's not the transfer characteristic
if (![characteristic.UUID isEqual:[CBUUID UUIDWithString:kFindMeCharacteristicUUID]]) {
return;
}
NSString *strMsg=[NSString stringWithFormat:#"didUpdateNotificationStateForCharacteristic %#, reason: %#", characteristic, error];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
- (void) peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
if (error)
{
NSString *strMsg=[NSString stringWithFormat:#"Failed to write value for characteristic %#, reason: %#", characteristic, error];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
else
{
NSString *strMsg=[NSString stringWithFormat:#"Did write value for characterstic %#, new value: %#", characteristic, [characteristic value]];
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:#"Test" message:strMsg delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
alertView=nil;
}
}
- (void)cleanup
{
if (!self.discoveredPeripheral.isConnected) {
return;
}
if (self.discoveredPeripheral.services != nil) {
for (CBService *service in self.discoveredPeripheral.services) {
if (service.characteristics != nil) {
for (CBCharacteristic *characteristic in service.characteristics) {
if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:kFindMeServiceUUID]]) {
if (characteristic.isNotifying) {
[self.discoveredPeripheral setNotifyValue:NO forCharacteristic:characteristic];
return;
}
}
}
}
}
}
[self.cbcManager cancelPeripheralConnection:self.discoveredPeripheral];
[self.delegate didDeviceDisconnected];
}
#end
`
If I understand you right you can write a value successfully to a characteristic but you don't get a pairing request.
The pairing is triggered by the peripheral. Meaning the peripheral has to refuse the write or read request of your central to a characteristic. Your central gets the refusal "unauthorized authentication" and then tries to pair with the peripheral and showing the pairing alert pop up you are waiting for. This is all done by core bluetooth automatically. The only thing you need to do is change the characteristics options and permissions in your peripheral. This is the apple sample code to trigger a pairing:
emailCharacteristic = [[CBMutableCharacteristic alloc]
initWithType:emailCharacteristicUUID
properties:CBCharacteristicPropertyRead
| CBCharacteristicPropertyNotifyEncryptionRequired
value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
source: CoreBluetooth_concepts iOS7 preview
Also check out the WWDC 2012 advanced core bluetooth video at 28 minutes they explain the concept of pairing.

How can we post something on facebook in ios 6 like twitter?

I am implementing facebook posting in my app. And add some code to post something on facebook account.
My code is as follows.
- (void)publishStory
{
NSLog(#"publish story called .......");
[FBRequestConnection
startWithGraphPath:#"me/feed"
parameters:self.postParams
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
#"error: domain = %#, code = %d",
error.domain, error.code];
} else {
alertText = [NSString stringWithFormat:
#"Posted action, id: %#",
[result objectForKey:#"id"]];
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:#"Result"
message:alertText
delegate:self
cancelButtonTitle:#"OK!"
otherButtonTitles:nil]
show];
}];
}
-(IBAction)cancelButtonAction
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)shareButtonAction
{
// Add user message parameter if user filled it in
if (![self.postMessageTextView.text isEqualToString:#""]) {
[self.postParams setObject:self.postMessageTextView.text
forKey:#"message"];
}
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions
indexOfObject:#"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
[FBSession.activeSession reauthorizeWithPublishPermissions:
[NSArray arrayWithObjects:#"publish_actions",#"publish_stream", nil]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// If permissions granted, publish the story
NSLog(#"not error");
[self publishStory];
}
}];
} else {
// If permissions present, publish the story
NSLog(#"In else condition");
[self publishStory];
}
}
this is too much code for , "as ios 6 contains integrated facebook in settings."
But I want to post like twitter integration in ios.How can we do that
There are two ways for posting.
1)Post using FBNativeDialog. (inlcude FacebookSDK.framework)
2)Post via SLComposeViewController.
Which one you want to use is up to you.You need to add three frameworks named AdSupport.framework,Accounts.framework and Social.framework.
For using first one you have to include #import "FacebookSDK/FacebookSDK.h" and code for posting is as follows:
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:#"" message:#"" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self initialText:#"" image:[UIImage imageNamed:#"iossdk_logo.png"] url:[NSURL URLWithString:#"https://developers.facebook.com/ios"]
handler:^(FBNativeDialogResult result, NSError *error)
{
if (error) {
alert.message=#"Fail posting due to some error!";
[alert show];
/* handle failure */
} else {
if (result == FBNativeDialogResultSucceeded) {
alert.message=#"Posted Successfully!";
[alert show];
/* handle success */
} else {
/* handle user cancel */
}
}}];
if (!displayedNativeDialog) {
/* handle fallback to native dialog */
}
For second one you need #import "Social/Social.h" and the code is as follows:
SLComposeViewController *fbComposer =
[SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=
^(SLComposeViewControllerResult result){
[fbComposer dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(#"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(#"Posted....");
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Sent"
message:nil
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles: nil];
[alert show];
}
break;
}};
[fbComposer addImage:[UIImage imageNamed:#"iossdk_logo.png"]];
[fbComposer setInitialText:#"The initial text you want to send"];
[fbComposer addURL:[NSURL URLWithString:#"https://developers.facebook.com/ios"]];
[fbComposer setCompletionHandler:completionHandler];
[self presentViewController:fbComposer animated:YES completion:nil];
}

in app purchase implemention

In My app I have to implement in app purchse in below scenerio:-
App is free for all user i.e every person can download it at free of cost.
I have implemented Consumable type for this.
in application there is a option to purchase 10 coins in $1.99.once user purchase it complete transaction successfully
but when again user click on purchased to 10 coins it prompted that "You have already downloaded this app".
I want to implement in app purchase in that wat so that user can purchase 10 coin s multiple type?
What will be type and scenario for this .
Please suggest?
- (void)requestProductData {
// NSLog(#"%#",strCheck);
if ([strCheck isEqualToString:#"inApp"]) {
myString = strCheck;
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:#"All_labelling"]];
request.delegate = self;
[request start];
}
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSArray *myProduct = response.products;
SKPayment *payment = [SKPayment paymentWithProduct:[myProduct objectAtIndex:0]];
[[SKPaymentQueue defaultQueue] addPayment:payment];
[request autorelease];
}
- (void)inAppPurchase {
reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus == NotReachable) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"LeaderFollow!" message:#"Network is not found" delegate:nil cancelButtonTitle:nil otherButtonTitles:#"Ok", nil];
[alert show];
[progInd stopAnimating];
[progInd setHidden:YES];
}
else if ([SKPaymentQueue canMakePayments]) {
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[self requestProductData];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Please enable the ability to make purchases." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (void)finishMyTransaction:(SKPaymentTransaction *)transaction {
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
self.view.userInteractionEnabled=YES;
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
[progInd stopAnimating];
[progInd setHidden:YES];
}
#pragma mark Payment Delegate
#pragma mark -
- (void)recordTransaction:(SKPaymentTransaction *)transaction {
}
- (void)provideContent:(NSString *)productIdentifier {
if([productIdentifier isEqualToString:#"All_labelling"]){
strCheck=#"inApp";
myString=strCheck;
}
if ([strCheck isEqualToString:#"inApp"]){
[prefs setBool:YES forKey:#"inApp"];
if(!isTapped){
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"Congratulations!" message:#"You Have Successfully Purchased All Objects Pack" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
[self viewWillAppear:YES];
}
//}
[progInd stopAnimating];
[progInd setHidden:YES];
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction {
[self recordTransaction:transaction];
[self provideContent:transaction.payment.productIdentifier];
[self finishMyTransaction:transaction];
}
-(IBAction)btnRestoreTapped{
[progInd setHidden:NO];
[progInd startAnimating];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
[[UIApplication sharedApplication]beginIgnoringInteractionEvents];
}
- (void)restoreTransaction: (SKPaymentTransaction *)transaction {
[self recordTransaction:transaction];
[self provideContent:transaction.originalTransaction.payment.productIdentifier];
[self finishMyTransaction:transaction];
}
- (void)failedTransaction: (SKPaymentTransaction *)transaction {
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:[transaction.error localizedDescription]
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
[self finishMyTransaction:transaction];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
default:
break;
}
}
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{
[progInd stopAnimating];
[progInd setHidden:YES];
[[UIApplication sharedApplication]endIgnoringInteractionEvents];
if([prefs boolForKey:#"inApp"]){
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"LeaderFollow!" message:#"You Have Successfully Restored Pack(s)" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
[prefs setObject:#"YES" forKey:#"Restore"];
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"LeaderFollow!" message:#"No purchases to restore" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
isTapped=NO;
}
- (void)paymentQueue:(SKPaymentQueue*)queue restoreCompletedTransactionsFailedWithError:(NSError*)error
{
[[UIApplication sharedApplication]endIgnoringInteractionEvents];
[progInd stopAnimating];
isTapped=NO;
self.view.userInteractionEnabled=YES;
[progInd setHidden:YES];
}

How do I Pull in errors when attempting to tweet from an iOS app using the Twitter+OAuth API?

How do I properly setup the callback method for a status update using the Twitter+OAuth API? (http://github.com/bengottlieb/Twitter-OAuth-iPhone)
Right now I'm using the following to determine if a request succeeded:
- (void)requestSucceeded:(NSString *)connectionIdentifier {
NSLog(#"Statuses Sent");
//[loadingActionSheet dismissWithClickedButtonIndex:0 animated:YES];
//[loadingActionSheet release];
}
What would I use to determine if a request failed?
Reading docs helps, implemented the following to solve my problem:
- (void) requestFailed:(NSString *)connectionIdentifier withError: (NSError *) error; {
NSLog(#"Status Update Failed");
NSLog(#"Error: %#", error);
[loadingActionSheet dismissWithClickedButtonIndex:0 animated:YES];
[loadingActionSheet release];
alert = [[UIAlertView alloc]
initWithTitle:#"Error" message:#"Twitter did not receive your update, please try again later." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}