Limit providers while integrating Gigya in iPhone? - iphone

I am integrating Gigya in my iphone app. Now it provides 17 providers for access, I want to limit it to just 9 providers. How can I do that?
Has any one integrated it for iPhone? It loads a web view which displays 17 providers in a grouped table format, see here.

To set Facebook and Twitter you can use following code.
GSDictionary *pParams5 = [[GSDictionary new] autorelease];
[pParams5 putStringValue:#"facebook,twitter" forKey:#"enabledProviders"];
[gsAPI showAddConnectionsUI:pParams5 delegate:self context:nil];

GSAPI *gsAPI // declare this
gsAPI = [[GSAPI alloc] initWithAPIKey:<API-KEY> viewController:self]; // i kept this in viewDidload
// add this code to have facebook and twitter on provider list
GSDictionary *pParams5 = [[GSDictionary new] autorelease];
[pParams5 putStringValue:#"facebook,twitter" forKey:#"enabledProviders"];
[gsAPI showAddConnectionsUI:pParams5 delegate:self context:nil];
//this method called when login fails
-(void)gsLoginUIDidFail:(int)errorCode errorMessage:(NSString*)errorMessage context:(id)context{ }
// this method called on successful login
- (void) gsLoginUIDidLogin:(NSString*)provider user:(GSDictionary*)user context:(id)context {}
Check whether you have valid API

Related

UIActivityViewController not Working With Facebook Login

I am using UIActivityViewController in my new app for Facebook Share Option.
But if the user not login to the device, it dont working.. When select setting, Login page not appearing..
IActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint];
[self presentViewController:activityVC animated:TRUE completion:nil];
What can i do on this..? Is that the Problem of my code or a Common Error..?
iOS 6 introduced both the UIActivityViewController class and Social Framework, both of which may be used to integrate Twitter, Facebook and Sina Weibo functionality into iOS 6 applications. For general purpose requirements, the UIActivityViewController and SLComposeViewController classes provide an easy to implement path to social network integration.
UIActivityViewController *activityController =[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
self presentViewController:activityController animated:YES completion:nil];
In order to use the SLComposeViewController class, a number of steps should be performed in sequence. Firstly, the application may optionally check to verify whether a message can be sent to the specified social network service. This essentially equates to checking if a valid social network account has been configured on the device and is achieved using the isAvailableForServiceType: class method, passing through as an argument the type of service required from the following options:
SLServiceTypeFacebook
SLServiceTypeTwitter
SLServiceTypeSinaWeibo
this is how you start ActivityIndicatorView with Loading lable
UIActivityIndicatorView *tempSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
lable =[[UILabel alloc]init];
lable.center = self.view.center;
lable.text = #"Loading...";
lable.hidden=NO;
lable.backgroundColor = [UIColor clearColor];
lable.textColor = [UIColor blackColor];
[lable sizeToFit];
lable.center = CGPointMake(160, 255);
tempSpinner.center = self.view.center;
[self.view addSubview:tempSpinner];
[self.view addSubview:lable];
start where ever you want like this
[tempSpinner startAnimating];
stop it like this where ever you want
[tempSpinner stopAnimating];
hide unhide loading label as per requirement

Is automated sharing possible for Twitter in the background on iOS?

I wanted to share a Twitter feed on the Twitter wall which contains an image and some text. I want support from iOS 4.3 to iOS 6.0.1. Is sharing possible in the background without a send/share button? How do I implement it?
The API call that you need to send is:
https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
Before making that call, of course, you will need to authenticate with Twitter via xAuth/OAuth. Unless you get special permission from Twitter to do otherwise, it looks like you will need to use OAuth,
https://dev.twitter.com/docs/oauth/xauth
To background the request, it will likely make sense to use Grand Central Dispatch --that is unless you have a lot of different Twitter requests to send. In that case, I would instead opt for an NSOperationQueue where maxConcurrentOperationCount = 1. See the following:
http://www.fieryrobot.com/blog/2010/06/27/a-simple-job-queue-with-grand-central-dispatch/
http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues
Nevertheless, because OAuth is such a pain, it will likely make sense to use a third party library. I've never used it before, but here is an example using MGTwitterEngine:
Twitter's statuses/update_with_media on iOS returns 500 error
If you were able to limit use to iOS 5+, then I would highly recommend using the SLRequest object. The advantage of this approach is that you integrate with the iOS users account directly, so they don't have to authenticate through a UIWebView or something cheesy.
To do so, you would simply plug in the appropriate Twitter API url in the following function requestForServiceType:requestMethod:URL:parameters: and obtain your SLRequest object. Then assign the appropriate Twitter ACAccount obtained from the ACAccountStore using requestAccessToAccountsWithType:options:completion:. Finally make your call to performRequestWithHandler, which would then perform your request asynchronously.
The following code will not post in background but it can post across ios versions...
You can use condition for ios versions like below code.This is working code I have implemented and it is working on both ios 5 and 6. Please check in ios 4 to confirm.I think it should work.
#import "Twitter/Twitter.h"
#import "Social/Social.h"
-(IBAction)tweetPost:(id)sender
{
if ([self isSocialAvailable])
{
SLComposeViewController *tweetComposer=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewControllerCompletionHandler __block completionHandler=
^(SLComposeViewControllerResult result){
[tweetComposer 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;
}};
NSString*message = #"posting to twitter test ios 6";
[tweetComposer setInitialText:message];
[tweetComposer addImage:[UIImage imageNamed:#"2.jpg"]];
[tweetComposer addURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
[tweetComposer setCompletionHandler:completionHandler];
[self presentViewController:tweetComposer animated:YES completion:nil];
}
}
else
{
TWTweetComposeViewController *twitter= [[TWTweetComposeViewController alloc] init];
[twitter addImage:[UIImage imageNamed:#"2.jpg"]];
[twitter addURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
[twitter setInitialText:#"Tweet from iOS 5 app using the Twitter framework."];
[self presentModalViewController:twitter animated:YES];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = #"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = #"Tweet compostion was canceled.";
else if (result == TWTweetComposeViewControllerResultDone)
msg = #"Tweet composition completed.";
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:#"Okay" otherButtonTitles:nil];
[alertView show];
};
}
}
-(BOOL)isSocialAvailable {
return NSClassFromString(#"SLComposeViewController") != nil;
}
You need to include three frameworks named social,adSupport and Accounts.Check which one not needed with twitter feed post.
Hope ,this will help you.
Yes, but you'll need find some 1.1 API wrapper (thing which generates API requests, singns them etc) for you and authoriser (MGTWitter engine works fine). I have a working solution for sharing (text only) and getting user info for iOS 4+.
And about background part - that depends on how you implement that (i.e. notifications or continious background execution or gps callbacs etc...).

How to implement AdMob in Phonegap

I have a phonegap application and im trying to implementing Admob.
I'm using phonegap version 1.4.1 and I am using this site as my reference : http://iphone.keyvisuals.com/iphonedev/implementing-admob-ads-in-a-phonegap-project-for-ios-no-plugins-required/
My code is as follows:
(void)webViewDidFinishLoad:(UIWebView *)theWebView
{
bannerView_ = [[GADBannerView alloc]init];
[bannerView_ setDelegate:self];
[bannerView_ setFrame:CGRectMake(0, 0, 320, 50)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self.viewController;
[self.viewController.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
// only valid if AdGap.plist specifies a protocol to handle
if(self.invokeString)
{
// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
NSString* jsString = [NSString stringWithFormat:#"var invokeString = \"%#\";", self.invokeString];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
return [ super webViewDidFinishLoad:theWebView ];
}
Everything is fine, but when I am running the application, no ads are being displayed.
Please make sure that your "theWebView" object finishes its webload. And that the bannerView_ is a registered property of your object.
Also, I hope you just put in "MY_BANNER_UNIT_ID" to hide your banner unit id.
Check up with your admob settings if the banner unit id is correct.
And finally, please use a iphone proxy like Charles or similar to validate that the call goes out as it should.
Phonegap has been upgraded. It support new features. just add this code in your config.
<gap:plugin name="com.admob.plugin" version="1.0.0" source="plugins.cordova.io"/>

Getting twitter account list in IOS-5 and user it with TWTweetComposeViewController

i am using Twitter with IOS - 5 integration. i used tweeting app provide by apple for this.I am using TWTweetComposeViewController for this.
But if i have more than 2 twitter accounts. it is getting my first account every time. but i want that list of my different account shown to me and then when i select one of account and then i can use it with TWTweetComposeViewController. i like to show like bellow image From :"username"
i have used this code :
- (IBAction)sendEasyTweet:(id)sender {
// Set up the built-in twitter composition view controller.
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
// Set the initial tweet text. See the framework for additional properties that can be set.
[tweetViewController setInitialText:#"Hello. This is a tweet."];
[tweetViewController addImage:[UIImage imageNamed:#"Icon.png"]];
// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
NSString *output;
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
// The cancel button was tapped.
output = #"Tweet cancelled.";
break;
case TWTweetComposeViewControllerResultDone:
// The tweet was sent.
output = #"Tweet done.";
break;
default:
break;
}
[self performSelectorOnMainThread:#selector(displayText:) withObject:output waitUntilDone:NO];
// Dismiss the tweet composition view controller.
[self dismissModalViewControllerAnimated:YES];
}];
// Present the tweet composition view controller modally.
[self presentModalViewController:tweetViewController animated:YES];
}
Unfortunately, TWTweetComposeViewController doesn't give you much configuration flexibility. If you tap on the account name it will pop up your list of accounts. TWTweetCVC does seem to remember the last account you tweeted with though.
If you use ACAccountStore you can get the list of the users Twitter accounts and you could provide your own UI to choose one but you cannot configure TWTweetComposeViewController to use it. If you couple that with TWRequest you can roll your own tweet sheet class and do this yourself.
DETweetComposeViewController is a drop-in replacement for TWTweetComposeViewController. It's open source, so you can modify it to meet your needs. It's also compatible with iOS 4.
Now , i am getting my it , and picker is showing for it as shown in image
so from this picker , i can select one of my account for tweet.

AdMob not showing ads in iOS simulator

I am trying to use AdMob on an app (built for iOS 4.0)
I've added the sample code available in the tutorial http://code.google.com/mobile/ads/docs/ios/fundamentals.html which is the following (I've changed the adUnitID):
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = #"XYZ";
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];
GADRequest * request = [GADRequest request];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];
Doing this nothing happens, no ad is shown and the number of requests in my AdMob app page increase erratically (i.e.: I can't seem to notice a pattern), but the most important is no ad is shown.
If I add the following code:
GADRequest * request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID, // Simulator
nil];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];
I get the "Success! You are now ready to travel through the App Galaxy" default banner, but only this one.
So my questions are:
Aren't the sample code enough to show ads? Why I never see an ad with the sample code?
As far as I understood, requests mean the number of times my app asked for an ad to be shown. I also understood that not every request is replied with an ad (otherwise the fill rate would be 100%), but still, I NEVER saw an ad, what am I doing wrong?
Thanks in advance.
GADBannerView *bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];//Set Position
bannerView.adUnitID = #"12331255421245";//Call your id
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView.rootViewController = self;
[self.view addSubview:bannerView];//Your attempt to add bannerview
// Initiate a generic request to load it with an ad.
[bannerView loadRequest:[GADRequest request]];
I set all above methods. Ad banner looks properly in Device but not showing ad in Simulator.
I set device Id as GAD_SIMULATOR_ID.but it doesnt work. Its delegate methods are not being called. !!
Try it in the device. Apps in simulator don't show Admob ads.