As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am first time implementing json in my app.
and in my app I have to pass parameters from my app to webservice and according to that i can get response from web service but I am not able to find any tutorial in which I can pass parameters from my app in ios5
so is there any tutorial on net from which I can get tutorial which is useful to me.
I tried to find using google but i did not succeed.
Following steps follow for the integrate the json in to our project.
1) Copy paste the below file into your project.
2) Create new Group name as help which contain the following files.
3) Create the new file into Support Files which is name as a constant.h
#define WEB_SERVICE_URL #"Your server url" //#"http://demo.google.com/webservice/"
#define USERNAME #"Your user id"//static username to send everytime
#define PASSWORD #"Your Password"//static password to send everytime
4) Change the above the variable link where is your web service exist that means url of your webservice ”WEB_SERVICE_URL”
5) Open “Rest.h” file and create the one method.
-(void)Get_StoreDetails:(SEL)seletor andHandler:(NSObject*)handler andCountryId:(NSString *)CountryCode;
6) Open “Rest.m” file and which argument to pass to server that method to code.
-(void)Get_StoreDetails:(SEL)seletor andHandler:(NSObject *)handler andCountryId:(NSString *)country_id{
NSDictionary *req = [NSDictionary dictionaryWithObjectsAndKeys:#"content/get_stores",#"request",
[NSDictionary dictionaryWithObjectsAndKeys:USERNAME,#"username",
PASSWORD,#"password",
country_id,#"country_id",
nil],#"para",nil];
[[[JSONParser alloc] initWithRequest:req sel:seletor andHandler:handler] autorelease];
}
7) now the Rest application is ready for the send the request and then now this method call in to our view controller.
Following code put into the “viewWillAppear” method in .h file
#import <UIKit/UIKit.h>
#interface JsonDemoAppViewController : UIViewController{
UIAlertView *alertCtr;
}
#property(nonatomic,retain)NSMutableArray *arrForStores;
- (void)getData:(id)object;
#end
Following code put into the “viewWillAppear” method in .m file and import “Rest.h”.
- (void)viewWillAppear:(BOOL)animated {
self.arrForStores=nil;
//============================Json Initialization===================================================
REST *rest = [[REST alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[rest Get_StoreDetails:#selector(getData:) andHandler:self andCountryId:#"12"];
alertCtr = [[[UIAlertView alloc] initWithTitle:#"\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alertCtr show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alertCtr.bounds.size.width / 2, alertCtr.bounds.size.height - 50);
[indicator startAnimating];
[alertCtr addSubview:indicator];
[indicator release];
//===================================================================================================
}
Then the reply comes into server that time object store into the variable that time we create the metod which calls.
- (void)getData:(id)object{
NSLog(#"%#",object);
if ([object isKindOfClass:[NSDictionary class]]) {
NSLog(#"Controll comes here..");
//IF your response type is NSDictionary then this code to run
}
if ([object isKindOfClass:[NSArray class]])
{
self.arrForStores=[NSArray arrayWithArray:(NSArray*)object];
//IF your response type is NSArray then this code to run
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[alertCtr dismissWithClickedButtonIndex:0 animated:YES];
}
Download the source code From Here
Related
I am doing VoIP call Application. There i can make call through my application. I have integrated SiriKit setup and added following code.
#pragma mark -Start Audio Call
- (void)resolveContactsForStartAudioCall:(INStartAudioCallIntent *)intent
withCompletion:(void (^)(NSArray<INPersonResolutionResult *> *resolutionResults))completion{
NSLog(#"maytest resolveContactsForStartAudioCall");
NSArray<INPerson *> *recipients = intent.contacts;
NSMutableArray<INPersonResolutionResult *> *resolutionResults = [NSMutableArray array];
if (recipients.count == 0) {
completion(#[[INPersonResolutionResult needsValue]]);
return;
}else if(recipients.count==1){
[resolutionResults addObject:[INPersonResolutionResult successWithResolvedPerson:recipients.firstObject]];
}else if(recipients.count>1){
[resolutionResults addObject:[INPersonResolutionResult disambiguationWithPeopleToDisambiguate:recipients]];
}else{
[resolutionResults addObject:[INPersonResolutionResult unsupported]];
}
completion(resolutionResults);
}
- (void)confirmStartAudioCall:(INStartAudioCallIntent *)intent
completion:(void (^)(INStartAudioCallIntentResponse *response))completion{
NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INStartAudioCallIntent class])];
INStartAudioCallIntentResponse *response = [[INStartAudioCallIntentResponse alloc] initWithCode:INStartAudioCallIntentResponseCodeReady userActivity:userActivity];
completion(response);
}
- (void)handleStartAudioCall:(INStartAudioCallIntent *)intent
completion:(void (^)(INStartAudioCallIntentResponse *response))completion{
NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INStartAudioCallIntent class])];
INStartAudioCallIntentResponse *response = [[INStartAudioCallIntentResponse alloc] initWithCode:INStartAudioCallIntentResponseCodeContinueInApp userActivity:userActivity];
completion(response);
}
But, its not making calls through my app. Its making calls through native dialer and some times showing application not yet set up with siri.
Could anyone guide me and after make call, how to save call history.
Thanks!
I encountered this problem too!!!
I my case, it's because I'm calling Siri in Chinese!!!! It takes me a half day to figure it out!!
If I change Siri language to English and everything works just fine!
In Chinese Siri will only call through native dialer no matter how I specify the application.
I'm not sure if it happens on other languages too since I can only test those two.
I have included AdMob in my iphone app. I have the following code in my viewDidLoad method:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
0.0,
320,
50)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = ADMOB_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;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[bannerView_ loadRequest:r];
[r release];
This leaks. When I comment out the second last line ( [bannerView_ loadRequest:r]; ), the leak disappears. The only thing I changed in this code from the example provided by Google was to introduce the variable r so I could put AdMob in testing mode. In the code supplied by Google, bannerView_ is released by viewDidUnload. I looked for the loadRequest method but all I found was a definition in the GADBannerView.h file. As far as I can tell, there is no GADBannerView.m file, which seems weird in itself. Anyway, any tips would be much appreciated.
Thanks,
John
Why don't you use this AdMediator - it is very simple to configure and you don't have to worry about AdMob and iAds (if you want to use it) :
will swap in AdMob ads if no iAds are
available.
Are you releasing bannerView_ in your dealloc method or somewhere else appropriate ?
Instead of:
GADRequest *r = [[GADRequest alloc] init];
You could try:
GADRequest *r = [GADRequest request];
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Could any one helpme with how to add admob codes in Appdelegate file.
Currently i have the following code in my appdelegate file.
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[web_online loadHTMLString:#"<h1>Loading...</h1>" baseURL:nil];
current_word = [[NSString alloc] initWithString:#"keyword"];
current_url = [[NSString alloc] initWithString:#"http://www.google.com"];
#if 0
if ([[NSUserDefaults standardUserDefaults] boolForKey:#"auto_correction"] == NO)
search_main.autocorrectionType = UITextAutocorrectionTypeYes;
else
search_main.autocorrectionType = UITextAutocorrectionTypeNo;
#endif
//search_main.keyboardAppearance = UIKeyboardAppearanceAlert;
search_main.autocorrectionType = UITextAutocorrectionTypeNo;
search_main.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self init_data];
[self init_sound];
[window addSubview:nav_main.view];
[window addSubview:view_start];
#ifdef DISABLE_ADMOB
view_ad.hidden = YES;
#endif
// Override point for customization after application launch
[window makeKeyAndVisible];
}
My question is how to add the admob codes ie the code below
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 = #"67576511260";
// 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_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
in the appdelegate file.
Everything else i have done.
All my code is done in appdelegate file . ie why this??
There's two questions to answer here.
Firstly, just put the code before the [window makeKeyAndVisible] replacing instances of [self view] with window and it should work.
Secondly, why is all that in your app delegate? The standard way of writing iPhone apps is to use a UIViewController with UIView objects (apple's variant on MVC) - this separates out your data and presentation code nicely.
More importantly here, all libraries like this will assume that you've used this pattern - hence you are finding trouble getting the admob code to work - it's designed to fit inside a UIViewController, not inside an app delegate.
Why have you decided not to use view controllers?
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
This question already has answers here:
Make a phone call programmatically
(13 answers)
Closed 8 years ago.
I would lie to place a call in my app (I can use the tel:) but I would like to return to my app where I left after the users hangs up.
Is that possible?
I got this code from Apple site and it works perfectly:
-(IBAction) dialNumber:(id)sender{
NSString *aPhoneNo = [#"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ; NSURL *url= [NSURL URLWithString:aPhoneNo];
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
if ([osVersion floatValue] >= 3.1) {
UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[webview loadRequest:[NSURLRequest requestWithURL:url]];
webview.hidden = YES;
// Assume we are in a view controller and have access to self.view
[self.view addSubview:webview];
[webview release];
} else {
// On 3.0 and below, dial as usual
[[UIApplication sharedApplication] openURL: url];
}
}
No it's not. The user controls where they navigate after the phone call has ended I'm afraid. by default, it stays in the phone application, and the only way for the user to exit out of it is to hit the home button, which takes them to their main screen. Save your state, and reload it when they come back like everyone else.
You cannot return to the app automatically, after the call completes, but if your app supports iOS 4, its multitasking features (if the app supports them) can bring the user back to the spot where he or she left off before the call, when the app is relaunched.
If you use iOS 3 or earlier, you will need to manually save the app's state yourself and then bring the user back to that state on relaunch.