Showing posts with label iphone. Show all posts
Showing posts with label iphone. Show all posts

Monday, June 10, 2013

iOS 7

Apple iOS has gone through 6 versions and now we are getting iOS 7. Announced at the WorldWide Developers Conference (WWDC) 2013, iOS 7 aimed to please with its massive redesign and fancy new features. It’s time to quench those rumors and check out what iOS 7 (beta still) has for iOS users.


While developers play with the beta version of iOS 7, which will be released for iPhone 4, iPhone 5, iPad 2nd generation and above, iPad Mini, and the 5th generation iPod touch, let’s check out what made the cut, what got updated, and the juicy details behind this latest update to the world’s most advanced mobile operating system yet.

1. UI Redesign – Flat, Simplicity

iOS has been redesigned, from the app icons and colors to typography, buttons and the general outlook — everything is simple and clean. The homescreen wallpaper uses gyroscope hardware to give the background picture a parallax effect. As you move your device, you can clearly differentiate the homescreen layer from the app icon layers, and this works throughout the system.

Translucent design on the keyboard as well as system-wide (Mail, Messages, Calendar, Game Center) are present throughout the OS; you get a view of what is happening at the back. Swipes form the left edge of the device brings you to the previous menu or back to the previous webpage. Pages for app folders have also been implemented, perfect for your ton of gaming apps.

The Notification Center now works on the lockscreen and also has a new look. You can see today’s notifications, missed notifications or all notifications through the buttons at the top. Calendar events are accessible with a single swipe all the way to the top.

2. One-Swipe Access Control Center

Access settings and options in a heart beat with Control Center. Swipe from the bottom of the screen to access settings like WiFi, Bluetooth and also change brightness and control music playback.

Control Center also allows you quick access to a few apps like the camera and calculator. It also lets you turn on the flashlight, and since Control Center works on the lockscreen, you’ll be able to turn the light on to find things in the dark without the need of finding an app.

3. Smarter Multitasking

Orientation lock and volume slider are also on the Control Center. Multitasking now lets you peek at the apps which are opened. Slide through all the app previews and double tap on a preview to launch the app.

iOS 7 recognizes your app usage patterns, and will allocate more resources for your favorite apps even with other apps open helping you to improve battery life. It’s even intelligent enough to know that you’re going to use Instagram around lunch time and will allocate resources for that behavior.

There’s also Intelligent Scheduling that works with networks where it will only push updates for an app when you have a strong network connection.

4. Safari’s New user Interface

Browsing the Web on Safari now is better with its automatic full screen mode. As you scroll down through content, the address bar that you normally see will be minimized to only show the website name. The buttons at the bottom will also be hidden until you scroll up to reveal the controls.

The address bar doubles as a search bar with new features: typing in part of a word will show you the Top Hit and also shows other Google search suggestions.

You can now open unlimited tabs on Safari. Scrolling through multiple tabs looks like you’re scrolling through a file cabinet, where you can only see the top. Just tap on the website to open it, tap and hold to rearrange the tabs or swipe it to the right to close it.

iCloud Keychain that saves password throughout all your Apple products featured on the new OS X Maverick is also integrated to Safari for iOS. Shared links by your Twitter followers are also convieniently located next to the Reader tab which syncs throughout your other devices.

5. AirDrop Sharing Between iOS Devices

AirDrop is now available for transfers between iOS devices via peer-to-peer WiFI connection. Turning on the Share Sheet on an app, you can find users who are nearby and tap items to share. A notification will appear on their device and when they open it, it will open to the relevent app and show the content that you shared.

Since it uses new hardware, AirDrop only works on the iPhone 5, 4th-gen iPad, iPad mini, 5th-gen iPod Touch.

6. Quick Camera, Geo-sorted Albums

The camera app now comes with 4 features accessible by left or right swipes: Videos, Photos, Photos in a square frame (for instagram) and Panorama pictures. New filters have also been added to the camera app on top of the basic editing features that is already available.

The Photos app also auto organizes your photos into moments based on location and date. It shows the location name and date when you first enter the Photos app. You can then pinch to zoom out and view collections where it sorts by locations only.

Zooming out again then shows you the photos taken, sorted by year. It can roughly tell you highlights of each year like you visiting another country for holiday. You can then tap, hold and swipe your finger across the small pictures for a quick view.


7. Siri & iOS In The Car

Siri is now smarter with integrated Wikipedia and Bing support built in for your search queries. There’s also Twitter where Siri can check out what your friends are saying. Other than Siri’s new look with the soundwave, it now shows results in a cleaner way.

Siri now also has a male voice, and can speak to you in French or German (more languages coming soon). Voice commands are also available for actions like "play my last voicemail", "turn on Bluetooth" or "increase brightness".



Because of these voice commands that let you change settings on the system, Siri will be integrated into 12 car manufacturers in 2014, which leads to the new feature called iOS In The Car.

With the powerful voice commands, you can easily call someone, play music, get directions with Maps or have messages read to you without you having to look at the car’s center console or iOS device.


8. iTunes Radio & More Music Control

Apple now has its own Radio app similar to services like Pandora. It’s built into the new Music app where you can see featured stations or songs that are trending on Twitter. You can create your own stations based on music genre or your favorite artist and then share it with your friends.

While music is streamed to you, you can choose to "play more songs like this" or "don’t play this song" and it’ll intelligently tweak the playlists further.



It keeps track of all the songs that you listen to on the History tab so you can opt to purchase it later. iTunes Radio is also available on your Mac, PC or Apple TV and is free with ads unless you’re a iTunes Match subscriber.

With the Music app update, you can see all your purchased music, movies and TV shows over iCloud on your device. Landscape mode also shows you all your album covers where you can just tap on a cover to start listening to it.


9. More Features

Here are a few more interesting things that you might want to know about iOS 7.

The App Store has changed where you can look for apps based on age range and view popular apps around you. Apps now also auto-update.

FaceTime will also feature audio only calls together with the ability to block numbers so they can’t reach you over the phone, FaceTime or messages.




Find My iPhone has an update with Activation Lock. Even if someone disables Find My iPhone or wipes the entire device clean, they won’t be able to use it as your iCloud user ID is required to use your device.

Notification syncing is also a new feature where notifcations that you’ve cleared will be gone throughout all your devices.

Tencent Weibo will also see more integration on iPhone.

Also, 1500 new APIs will be released to developers to integrate all the cool new features and looks of iOS 7 to their apps, so expect more features to turn up when iOS 7 comes to your iDevices this fall.

Friday, June 17, 2011

Monetizing your iOS app (iAd integration)

With iOS SDK 4, Apple has given a new way to integrate third-party ads and earn more revenue from your iOS application.
In this tutorial I will show how to integrate iAd and supporting both portrait and landscape ad into your app.

Here is what we will get working after this tutorial


Step 1: Base SDK vs Deployment Target
The first step to use iAd is to make sure our project has the right Base SDK and iPhone OS Deployment Target selected.

For those of you confused about the difference between the Base SDK and Deployment Target (like I was for quite some time!), here’s what they mean:

* The Base SDK is the version of the SDK you are linking against. Your app can use any classes or functions available in the version of the SDK you choose here – as long as they are available on the actual device the code runs on.
* The Deployment Target is the earliest possible version of the SDK your code can run on. This can be an earlier version than the Base SDK – in fact you often want to set it to be earlier to ensure that as many different versions of the OS can run your code as possible!

The tricky bit is what happens when you want to use a class, function, or framework available in one version of the OS if it’s available, but still work on the old version of the OS if it isn’t.

For this tutorial, we will stick on using iOS 4 (or later) as target SDK since iAd was introduced after this version only.

But as a side note, lets also explain the case where we want to set things up so that our code can use stuff available in iOS 4.0 (such as iAd), but still run on as many devices as reasonable (3.0+). Just a few more steps are involved in it.

So first let’s set iOs 4.0(or later) as the base SDK. Then, let’s set iPhone OS 3.0 as the iPhone OS Deployment Target.



You should now be able to compile and run your app (use the iPhone simulator), and try it out on an iPhone 4 simulator. But if you try to run it on iPhone 3 simulator, your app will crash. Lets fix it up.

Linking Against the iAd Framework
The next thing we need to do is add the iAd framework to the project. You can do this by right clicking on Frameworks, choosing “Add\Existing Frameworks…”, and choosing “iAd.framework” (for Xcode 3) or adding "iAd.framework" under Build Phases of your applicatin Target module.



The problem is, if that is all we do our code will break on older devices that don’t have the iAd framework.
To fix this, we need to weak link against the iAd framework. Expand the Targets directory, right click on PortMe, and choose “Get Info”. Click the Build tab, make sure “All Configurations” is selected, and navigate to Linking\Other Linker Flags. Double click on that entry, click the “+” button, and type “-weak_framework iAd”.
Click OK, and then try your app on the iPad simulator again and viola – it should work!

Step 2: Start iAd integration programmatically (.h file)

First make the changes in your View Controller .h file to look like this.



We first include the iAd headers and mark the view controller as implementing the ADBannerViewDelegate. This way, we can receive events as ads become available or not.
We then declare the ADBannerView which will be your view holding and displaying the ads.We also declare a variable (bannerIsVisible) to keep track of our iAd banner view, and whether or not it’s currently visible.

Step 3: Some memory management in .m file



Fist synthesize your variable bannerIsVisible. Then do some memory management stuff by releasing your ADBannerView's instanceadView in dealloc method.

Step 4: Main 4 delegate methods doing all heavy-lifting for iAd integration



The first method is called up when the Banner View is loaded for the first time and ads become available for display. Here we set the variable bannerIsVisible to YES.
- (void)bannerViewDidLoadAd:(ADBannerView *)banner


The second method is called upon the failure to load the Ad View due to any reason (no internet connection or other..)
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error


Thisd method is called up when user taps on the iAd and the full-screen iAd gets loaded up. We should pause our main application at this point as the user is interating with the ad this whole time and we free-up maximum resources as our app does not needs it at that time.
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave


The last method is called when user closes the iAd. Here we should resume our application processes again.
- (void)bannerViewActionDidFinish:(ADBannerView *)banner


Step 5: Initialize iAd in viewDidLoad Method

We need to initialize the ADBannerView in our viewDidLoad method ie; when our view gets loaded. Here we set all the required variables of ADBannerView (like frame, contentSize etc.) and add this view as a subview to our main ViewController's view.



Now, Build and Run the code, you should get your app up and running and iAd getting displayed on the screen.

Step 6: Support for multiple orientations

Till now we are able to integrate iAd into our application but it supports only portrait mode. Lets get it supported in all modes.



First we enable our application's support for all orientations and then we call a method
- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation
whenever the orientation of the device gets changed.

fixupAdView:


- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation {
if (adView != nil) {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[adView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
} else {
[adView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
[adView setFrame:CGRectOffset([adView frame], 0, -[self getBannerHeight:toInterfaceOrientation])];
}
}


And here's the method which gives the Banner height depending on device's current orientation


- (int)getBannerHeight:(UIDeviceOrientation)orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
return 32;
} else {
return 50;
}
}


That's all required to make iAd support multiple orientation.

The best feature of this code is that it could be used for any iOS application (iPhone as well as iPad app) without any change.

Get the final code (and more polished one) from here.

You must now have a complete overview of integrating iAd into your next app. So get started!

Tuesday, March 1, 2011

Code Snippet: Character Counter

Many of us had a need to display an editable UITextView/UITextField in which only certain number of characters could be entered. It could be assumed something similar to Twitter clients as maximum length of any tweet cannot exceed by 140 characters limit. Today, we will implement this functionality in our application.

Step 1:
Let's define a UITextField where user will enter the text and a UITextView where the remaining characters will be displayed. Declare the following in your controller.h file
@interface RemainingCharacterViewController : UIViewController {
IBOutlet UITextView * remainingTextView;
}

@property (nonatomic, retain) IBOutlet UITextView * remainingTextView;

-(void)textFieldDidUpdate:(id)sender;


The above code is pretty straight forward. We first declare an IBOutlet for the UITextView that we will be updating. It will be used to show our characters remaining. Next, we declare an IBAction that will be called every time the user types a character in the UITextField. Now that our properties and actions have been set up, it’s time to create our interface. We won't need to declare the IBOutlet for UITextField which user will be editing as we could identify it by the (id)sender parameter.

Step 2:
Open up the Interface Builder and add a UITextView and connect the remainingTextView outlet to this element. Next, you will need to connect the textFieldDidUpdate IBOutlet to the Editing Changed action of the UITextField. Thus, whenever the text inside this textField is changed, it will fire the textFieldDidUpdate method.

Step 3:
textFieldDidUpdate is the method where we will put up all our code. Open the viewController.m file and add the following code;
@synthesize remainingTextView;

-(IBAction) textFieldDidUpdate:(id)sender {
UITextField * textField = (UITextField *) sender;
int maxChars = 140;
int charsLeft = maxChars - [textField.text length];

if(charsLeft == 0) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"No more characters"
message:[NSString stringWithFormat:@"You have reached the character limit of %d.",maxChars]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}

remainingTextView.text = [NSString stringWithFormat:@"%d characters remaining.",charsLeft];
}

- (void)viewDidUnload {
remainingTextView = nil;
}

- (void)dealloc {
[super dealloc];
[remainingTextView release];
}


First, we keep the maximum character limit to be 140 characters. Then we find the difference between this max. character limit and the characters entered in the textField. If this difference is 0 then we have reached our maximum limit, hence notify the user with a pretty alert message.
Now you are all done with the implementation of character counter.

Thursday, February 10, 2011

Sending In-App SMS

With the release of iPhone OS 3, a new feature to allow sending of in-app email was introduced. And now in iOS 4, a similar way of sending in-app SMS is introduced.

Prior to iOS 4, developers have to depend on:
[[UIApplication sharedApplication] openURL: @"sms:99999999"];


It has various limitations. First, it just closes your app (or sends it in background) and opens the default SMS application. Secondly, there was no way to specify the body content of the SMS. Then, it also restricts you to send the SMS to only one person.

However, with the new MessageUI SMS Controller, users can send SMS without quitting the app.

Step 1
Import the MessageUI Framework into your project and #import the header file into the “.h” file of your controller where you want to open the In-App SMS sheet.

Step 2
You would need a button handler IBAction where you want to send the SMS. If you don't have it, create a Button on your XIB file and write IBActions for it.

Step 3
Now connect the above button to this method to fire this action on "On Touch Up" event.
-(IBAction) sendInAppSMS:(id) sender
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = @"Test message for in-app SMS";
controller.recipients = [NSArray arrayWithObjects:@"98765432", @"19283746", nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}


The above block of code is self-explanatory. The most important part here is the line [MFMessageComposeViewController canSendText].
Before trying to send an in-app SMS you would always need to make sure that the device is capable to do it or not. For eample, iPhone OS 3 devices and iPod touch don't have the ability to send in-app SMS.
In this case, I have used a if condition to send the SMS. Practically speaking, you should enable/disable the button the user taps to send the sms based on this. You can add the code that does this in your viewDidLoad method.

Secondly, you have to set the messageComposeDelegate to self and not delegate. If you set the controller.delegate to self, you will not get the didFinishWithResult callback and the In-App SMS sheet will not close.

Step 4
Implement Delegate Callbacks.
In your header file, implement the callbacks, MFMessageComposeViewControllerDelegate and UINavigationControllerDelegate. If you don’t you will get a warning at the line,
controller.delegate = self;


You have to handle a callback method of MFMessageComposeViewControllerDelegate so as to dismiss the modal view controller.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"IN-app SMS" message:@"Some Error occurred"
delegate:self cancelButtonTitle:@”OK” otherButtonTitles: nil];
[alert show];
[alert release];
break;
case MessageComposeResultSent:
NSLog(@"Message sent successfully");
break;
default:
break;
}

[self dismissModalViewControllerAnimated:YES];
}


That’s it. Your app should now be able to send SMS using the new Message UI sheet.

Note: As of today, the MFMessageComposeViewController doesn't support sending MMS. The controller.body is a NSString and setting a NSData pointer obviously crashes the app. Hopefully, one day, Apple will allow sending In-App MMS. Happy Coding till then...