GameCenter Leaderboards Not Updating in iphone Development

Being an ios game developer and you are integrating game center with your game. You may face this problem, when your application at sandbox environment your scores at Leaderboard not updating. Apple separates sandbox from Live server database, Because your Friends might see what game you are playing, to eradicate this kind of problem apple provides separate servers for sandbox,this data would be periodically erased,so i think that you may not get that Leaderboard problem,once your application enters in Live,

Reading Bundle Name from info.plist file in iphone development

Now we are going to read Bundle Name from info.plist file,first we need to read plist file and store it in NSDictionary.

NSDictionary *infoDictionary=[ [NSBundle mainBundle]infoDictionary];

to read Bundle Name,

NSString *BundleName = [infoDictionary objectForKey:@”CFBundleName”]; // short Display of the name

NSString *BundleName = [infoDictionary objectForKey:@”CFBundleDisplayName”]; // Actual name of the app,,,,is it Useful?

Reading version from info.plist file in iphone development

We can read our info plist file as Dictionary ,here is the code for reading version number for your application.

NSDictionary *infoPlist = [NSBundle mainBundle]infoDictionary];

we stored info.Plist file as dictionary value, now we read version number from that

NSString *VersionNum = [infoPlist objectForKey:@”CFBundleVersion”];

i hope that this might be useful, thanks in advance for your feedback and queries.

home Button and Lock Button Event Handling in iPhone development

when you are developing game or app in ios, you should handle these events ,users may press HOME button or LOCK button ,or your application may get interrupted during call ,SMS . Now i hope that you understand the reason why we should handle that ,for this problem apple has some delegate functions in app delegate
-applicationDidEnterBackground;
               this method invokes when application enters background(HOME button pressed).
 
-applicationDidBecomeActive;
              this method invokes when application become active and about to start running your app.
 
-applicationWillResignActive;
              this method invokes when application resigns active.
 
-applicationEnteredForeground;
             this method invokes when your app comes to foreground.
 
these methods are life cycle codes in iphone development.
expecting your feedback.Thank you

CoreLocation tutorial in iphone development

Implementing Built-in GPS in your app, it gives more advantage to you and users feel more comfortable with your apps, in ios development implementing this ,is very simple . Apple has powerful framework to do this,namely CoreLocation frameWork.But one thing is if you didnt properly use this methods,it would consume more power, so you have to do it properly,shutdown it as procedure,by doing this CoreLocation framework would consume less power, now we have look at this framework.

Since we’re going to be using Core Location with our iOS app, we need to add the header file (CoreLocation/CoreLocation.h) to our prefix header (usually with the extension .pch). In this prefix header, locate the #ifdef __OBJC__ line,

#ifdef __OBJC__

    #import

    #import

    #import  // added for Core Location

#endif

 

Next step is add CoreLocation framework in your project.by right click on frameworks->add existing framework->CoreLocation frameWork,

 

this framework has some important delegate methods,

 

We need to implement two important delegates in our class where we want to get messages ,

 

(void)locationManager🙁CLLocationManager *)manager didUpdateToLocation🙁CLLocation *)newLocation fromLocation🙁CLLocation *)oldLocation

 

this method will be called when new location messages recieved..

 

(void)locationManager🙁CLLocationManager *)manager didFailWithError🙁NSError *)error

 

This Delegate will be invoked if corelocation needs to report us failure messages,

 

Next we need to store the data where we currently located, for this add these two lines in @interface definition file.

 

@property (strong, nonatomic) CLLocationManager *locationManager;

@property (strong, nonatomic) CLLocation *currentLocation;

 

and add this line in @implementation file

 

@synthesize locationManager, currentLocation;

 

 

IMPLEMENTATION :

 

(void)locationManager🙁CLLocationManager *)manager didUpdateToLocation🙁CLLocation *)newLocation fromLocation🙁CLLocation *)oldLocation {

    self.currentLocation = newLocation;

 

    if(newLocation.horizontalAccuracy <= 100.0f) 

    {

         [locationManager stopUpdatingLocation]

    }

}

 

 

– (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {

    if(error.code == kCLErrorDenied) {

        [locationManager stopUpdatingLocation];

    } else if(error.code == kCLErrorLocationUnknown) {

        // retry

    } else {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Error retrieving location”

                              message:[error description]

                              delegate:nil

                              cancelButtonTitle:@”OK”

                              otherButtonTitles:nil];

        [alert show];

    }

}

 

REQUESTING UPDATES:

 

to setup corelocation you need to add these two line.

 

locationManager = [[CLLocationManager alloc] init];

locationManager.delegate = self;

[locationManager startUpdatingLocation];

 

Thats it,

I hope that this article might be useful, post your reviews and feedback below here to improve my skills.

best blogs ,sites and resources for iphone development

https://developer.apple.com/

              From this site, you can sign up for the developer program and download the necessary tools required to build iPhone apps. There is a developer fee of $99/annually in order to submit your newly built creations to have them appear on the app store, but you can download the tools and play around with them with a free account. 

http://iphonedevsdk.com/

                iPhone Dev SDK is a community for software developers interested in the iPhone SDK platform. Founded in March 2008, iPhone Dev SDK was one of the first communities for this revolutionary new platform.

What separates iPhone Dev SDK from the others is the friendly atmosphere the community provides for developers of all abilities. Whether you’ve been programming your entire life or are just now getting interested, you’ll find yourself welcomed to the community.

http://www.icodeblog.com/

               iCodeBlog.com features some of the best tutorials on the web, both on beginning and more advanced development concepts. It should get the novice beginner off to a good start as well as teach the established user a few things about parts of the API that they may have not explored yet. The blog is updated on a regular basis and would make a great addition to any iPhone developer’s bookmarks. 

https://www.adwhirl.com/

         Go through this site to earn more money with free apps with ad integration .

http://ideaswarm.com/

            useful one for tracking your application sales and graph .

getting ip address in iphone development

NSString*  ip=@“http://www.whatismyip.org/”;

NSURL *url = [[NSURL alloc] initWithString:ip];

NSString *ans = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];

NSLog(@“%@”,ans);

one more method

 

 

Import UIDevice-Reachability.h in your project then try with one of those commands:

NSString *myIp = [UIDevice localIPAddress];

NSString *myIp = [UIDevice localWiFiIPAddress];

NSString *myIp = [UIDevice whatismyipdotcom];

 

How to get country name and country code in iOS development

  NSLocale *locale = [NSLocale currentLocale];

    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

   

    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode

                                                                             value: countryCode]];

use this string for your use..

there is a drawback in this code ..this will not return string in english it returns that string in device language what user used in device,,, to get string alwys in english

use this code 

 

NSLocale *locale = [NSLocale currentLocale];

NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@“en_US”] autorelease];

NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode];

how to dynamicly alerts users from web by existing users , when you launch new app.

Screen 20Shot 202011 09 30 20at 202 12 47 20PM

Often times you find yourself in a situation where you might want to control your application remotely. You may want to enable/disable features at a certain time, push messages to all of your users, or do some cross promotion whenever you launch a new application. All of this can easily be done with a little JSON and some simple web interface coding.

In this tutorial, I will show you how to use ASIHTTPRequest along with JSONKIT to fetch, parse, and interpret remote JSON that will ultimately change how our application behaves. For this example, we are going to make a simple “nag” popup that will nag the user to download your latest application. When you set a remote flag to true, all users will see the popup every time they launch the application. The popup will also display a dynamic message from the web and link to a location specified in the JSON.
1. The JSON

First, let’s chat a little bit about the JSON we will be using. Here’s what it will look like:
{
“nag”: true,
“message”: “Check out Smart Lockscreen Creator!”,
“url”: “http://itunes.apple.com/us/app/smart-lockscreen-creator/id419890996?mt=8″
}
The field names should be pretty self explanatory. We will use JSON kit to parse these fields into an NSDictionary.
2. The Libraries

As mentioned before, we will be using 2 libraries to get the job done.
ASIHTTPRequest ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier.
JSONKit – A JSON Parser written in C with an Objective-C wrapper.
Make sure you download their source and follow each of their instructions for setting up your project to use them. JSONKit is pretty much drag in the source and you are good to go. ASI has a few framework dependancies that you are going to have to work out. The instructions for setting it up are here.
3. The Code – Download And Parse

You can add the code to fetch and control your application wherever you see fit, however I have added mine to the application’s delegate method.
// 1. Fetch out to the web
NSURL *url = [NSURL URLWithString:@”http://f.cl.ly/items/2y141v3O0G2e2Y2W3P24/alert.json”];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

// 2. Completion block
[request setCompletionBlock:^(void) {
NSString *responseString = [request responseString];
// 3. parse the response
NSDictionary *responseDict = [responseString objectFromJSONString];

// 4. pull out data
BOOL nag = [[responseDict objectForKey:@”nag”] boolValue];
NSString *message = [responseDict objectForKey:@”message”];
self.nagURL = [NSURL URLWithString:[responseDict objectForKey:@”url”]];

// 5. If nag is true, then show the alert
if(nag) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@”Message”
message:message
delegate:self
cancelButtonTitle:@”Cancel”
otherButtonTitles:@”Go”,nil] autorelease];
[alert show];
}
}];
// 6. Start the request
[request startAsynchronous];
In #1, we fetch out to the web and pull down the json string that contains our configuration settings. #2 sets the completion block for the request. If you are unfamiliar with this pattern, the request fires off in a new thread and the block gets executed AFTER the request completes. That way, we can keep all of our code in line rather than messing around with target and selector callbacks.
For #3, we are using JSONKit’s category on NSString that returns an NSDictionary representation of the JSON string. It couldn’t be easier.
Line #4 is where we extract the info from the dictionary and assign it to local variables. We set the nagURL global property here as well. The reason we must create a property for nagURL is we need to use it again in the delegate method for the UIAlertView in order to send the user to the url specified from the web.
Line #5 is where we check if nag is true and then show the alert. Make sure to set the delegate to our calling class so that we can respond accordingly.
Finally, in #6, we start the request asynchronously.
The last thing to do is implement the delegate method for the alert view. It’s pretty straight forward:
– (void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if(buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:self.nagURL];
}
}
We simply check to see if the user pressed the “Go” button, if so, we send them to the URL specified by the nagURL property.
Conclusion

And there you have it. A very simple example of how you can control some portion of your applicaiton’s functionality based on remote web data. You could expand upon this in a number of ways including:
Enabling/Disabling parts of the app
Loading “News” in some sort of ticker
Daily promotions
Promote new apps
Daily content (jokes, words, inspiration, scripture, etc…)
If you have any questions or comments, you can leave the here