iostwittertwitter-oauthsocial-framework

Multiple twitter login at same time IOS app


I have an application that i need to integrate with twitter login, for logging in via their twitter account. In the application we also have Twitter sharing option. Here i want to implement functionality to choose their account in which account they want to share the tweet. If user is logged in for only one account, then there should be provision to login to another account without logging out of existing logged-in account.


Solution

  • ====>Download Third Party Class FSHTwitterEngine.

    {

    [[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"6XITOIDiXNajx7TQMKOh8qDxj" andSecret:@"w4F44ATueFsarNjGQ9WDdEudJCBJ8P0o5zeNON5bP9hIKhGls6"];

        [[FHSTwitterEngine sharedEngine]setDelegate:self];
        [[FHSTwitterEngine sharedEngine]loadAccessToken];
    
        UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
    
    
            NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
    
            [self performSelector:@selector(TwitterPostMessage) withObject:nil afterDelay:1.0];
    
    
    
        }];
        [self presentViewController:loginController animated:YES completion:nil];
    

    }

    -(void)TwitterPostMessage {

    UIImage *aimg = [UIImage imageNamed:@"mark"];
    
    // [[FHSTwitterEngine sharedEngine]postTweet:@"Hepp adsfihdf sdfhihdsfh" withImageData:UIImagePNGRepresentation(aimg)];
    
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        @autoreleasepool {
            //NSString *tweet = [alertView textFieldAtIndex:0].text;
            // id returned = [[FHSTwitterEngine sharedEngine]postTweet:@"Post of image"];
    
            id returned = [[FHSTwitterEngine sharedEngine]postTweet:@"Hi Successfully Post Twitter..." withImageData:UIImagePNGRepresentation(aimg)];
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    
            NSString *title = nil;
            NSString *message = nil;
    
            if ([returned isKindOfClass:[NSError class]])
            {
                NSError *error = (NSError *)returned;
                title = [NSString stringWithFormat:@"Error %d",error.code];
    
                message = error.localizedDescription;
            } else {
                NSLog(@"%@",returned);
                title = @"Tweet Posted";
                message = @"Post of image";
            }
    
            dispatch_sync(dispatch_get_main_queue(), ^{
                @autoreleasepool {
                    UIAlertView *av = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [av show];
                }
            });
        }
    });
    

    }