I found little snippet from twitter about how to know if application is installed via TestFlight.
Here, appStoreReceiptURL
is an instance property, which we can find from main bundle.
Here, I am adding snippet for both Objective-C and Swift.
Objective-C
Push Notifications in iOS 10 [Objective-C]
The new framework called “UserNotifications” is introduced with iOS 10 SDK. The UserNotifications framework (UserNotifications.framework) supports the delivery and handling of local and remote notifications. So, Let see what we have to change to get the push notifications in iOS 10.
Steps for implement code to handle push notifications in iOS 10
Import UserNotifications.framework in your AppDelegate file
1 |
#import <UserNotifications/UserNotifications.h> |
Also add UNUserNotificationCenterDelegate.
1 2 3 4 |
#import <UserNotifications/UserNotifications.h> @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate> @end |
Register for push notification
Before registration check the version of iOS and then based on versions do the code. For iOS 7 code was different, fro iOS 8 & 9 code was different and again for iOS 10 code is different.
As per my opinion you have to set the deployment target to iOS 8 or iOS 9 and later. For this you can check the adoption ratio of iOS in the devices.
Define constant for version check :
1 |
#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) |
Add code in your did finish launching
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [self registerForRemoteNotifications]; return YES; } - (void)registerForRemoteNotifications { if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")){ UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ if(!error){ [[UIApplication sharedApplication] registerForRemoteNotifications]; } }]; } else { // Code for old versions } } |
Handling delegate methods for UserNotifications
You will be surprise that notification displayed when application in foreground too in iOS 10. As we know that in old versions we display alert or something else which will be look like notification comes in foreground.
There are two delegate methods need to be handled :
1 2 3 4 5 6 7 8 9 10 11 |
//Called when a notification is delivered to a foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ NSLog(@"User Info : %@",notification.request.content.userInfo); completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); } //Called to let your app know which action was selected by the user for a given notification. -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{ NSLog(@"User Info : %@",response.notification.request.content.userInfo); completionHandler(); } |
Add Push Notifications Entitlements
Go to your project target’s Capabilities tab and add Push Notifications Entitlements.
If it’s available in your certificates then it will enable directly else configure your profile with the certificates and you can enable this capability by that.
All Done!
Happy Coding ?
I have added sample code of objective-c on github with iOS 8, 9 and 10 support of push notification.
I have also posted about Push Notifications in iOS 10 [Swift].
iOS 10 New Frameworks
- CallKit
The CallKit framework (CallKit.framework) lets VoIP apps integrate with the iPhone UI and give users a great experience. Use this framework to let users view and answer incoming VoIP calls on the lock screen and manage contacts from VoIP calls in the Phone app’s Favorites and Recents views. - Intents
The Intents framework (Intents.framework) supports the handling of SiriKit interactions. - IntentsUI
The Intents UI framework (IntentsUI.framework) supports the creation of an Intents UI extension, which is an optional app extension that displays custom content in the Siri or Maps interfaces. - Messages
To develop an iMessage app, you use the APIs in the Messages framework (Messages.framework) and To create app extensions that interact with the Messages app, allowing users to send text, stickers, media files, and interactive messages. - Speech
Using the APIs in the Speech framework (Speech.framework), you can perform speech transcription of both real-time and recorded audio. - UserNotifications
User Notifications framework (UserNotifications.framework), which supports the delivery and handling of local and remote notifications. - UserNotificationsUI
User Notifications UI framework (UserNotificationsUI.framework) lets you customize the appearance of local and remote notifications when they appear on the user’s device. - VideoSubscriberAccount
Video Subscriber Account framework (VideoSubscriberAccount.framework) to help apps that support authenticated streaming or authenticated video on demand (also known as TV Everywhere) authenticate with their cable or satellite TV provider.
References :
How to add an Objective-C file in your Swift Project? or How to set Objective-C bridging header?
To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add an Objective-C file to an existing Swift app.
If you accept, Xcode creates the header file along with the file you were creating, and names it by your product module name followed by adding “-Bridging-Header.h”.
Alternatively, you can create a bridging header yourself by choosing File > New > File > (iOS or OS X) > Source > Header File.
You’ll need to edit the bridging header file to expose your Objective-C code to your Swift code.
To import Objective-C code into Swift from the same target
- In your Objective-C bridging header file, import every Objective-C header you want to expose to Swift.
For example:
[code language=”obj-c”]
#import "XYZCustomCell.h"
#import "XYZCustomView.h"
#import "XYZCustomViewController.h"
[/code] - Under Build Settings, make sure the Objective-C Bridging Header build setting under Swift Compiler – Code Generation has a path to the header.
The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you should not need to modify this setting.
Any public Objective-C headers listed in this bridging header file will be visible to Swift. The Objective-C functionality will be available in any Swift file within that target automatically, without any import statements. Use your custom Objective-C code with the same Swift syntax you use with system classes.
For Example:
[code language=”obj-c”]
let myCell = XYZCustomCell()
myCell.subtitle = "A custom cell"
[/code]
Helping, Learning, Coding 🙂
Source : Apple Documents
Add Launch Screen (LaunchImage) for iPhone 6 | 6 Plus in Xcode 6 | iOS 8
Hello Developers,
Greetings for iPhone 6, 6 Plus and Xcode 6 GM Seed !!
Question is how to add launch screens for iPhone 6 and 6 Plus.
As per Apple’s Guidelines create the launch screens :
For iPhone 6: 750 x 1334 Pixels Resolution
For iPhone 6 Plus: 1242 x 2208 Pixels Resolution
You have two options :
- Create launch screen by LaunchScreen.xib.
- Add Launch Images in assets folder.
Finally set the Launch Screen Settings :
Happy Screening 😉
Helping, Learning, Coding 🙂