Posts

iOS 11 - Autofill Passwords

Image
In this tutorial, we will discuss about AutoFill password feature available in iOS. Remembering passwords that we create in multiple applications is not only hard but also has risk to forget sooner or later. Then we have to use Forgot Password feature to set a reset your password.  Auto-filling passwords is available in Web for a long time. Though iOS Safari provided this feature of auto populating passwords for mobile websites, the native applications are left behind and users have to take responsibility for their passwords. Starting from iOS 11,  Apple provide an exciting feature where native apps can use this auto-filling passwords in applications. Which means, user from iOS 11 don't have to necessarily remember their passwords using in their apps. What we should do? We would be using UITextInputTraits protocol, and set the ‘textContentType' property. UITextInputTraits protocol defines features associated with the keyboard input to a text object. Set

Singleton static object

To create static shared object, that can be used across all view controllers .h + (id) sharedCustomAppController; .m static CustomApplicationController *sharedCustomAppController = nil; + (id) sharedCustomAppController {    @synchronized (self) {        if (sharedCustomAppController == nil) {            sharedCustomAppController = [[CustomApplicationController alloc] init];        }    }    return sharedCustomAppController ; }

NSError - Custom localised messages

NSError can be customised to deliver localized messages to the user. This is meant to show meaningful messages based on situations where and when error happens. 1. Create a strings file. As iOS supports localization, we need to add "strings" file to our project and add the error messages. "99" = "Exception occurred" "100" = "Login Successful."; "101" = "Logout failed"; "102" = "Unable to connect server"; "103" = "Invalid input data"; 2. Add two macro that would help to fetch the localized messages. #define ERROR_KEY(code)                    [NSString stringWithFormat:@"%d", code] #define ERROR_LOCALIZED_DESCRIPTION(code)  NSLocalizedStringFromTable(ERROR_KEY(code), @"Error", nil) // "Error" is the strings file name.

Debug logs

To enable debug logs in iOS application, add the following code in project PCH file. #if defined (DEBUGLOG) #define DebugLog( s, ... ) NSLog( @"%@", [NSString stringWithFormat:(s), ##__VA_ARGS__] ) #else #define DebugLog( s, ... ) #endif

Convert HEX code to RGB

To use hex code in UIColor, use the below macro. #define UIColorFromRGB(rgbValue) [UIColor \        colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \        green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \        blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] //Then use any Hex value self.view.backgroundColor = UIColorFromRGB(0xD2691E); 

Custom Message extension using Messages SDK - iMessage App store

Image
In our previous article , we discussed about creating custom sticker extension for our iMessage App store. We used images and using Messages SDK, we are able to create the custom extension for sticker. We also created a basic sticker extension in this article . Apple Messages SDK provides lot more features than just creating stickers. In today's article, we will create a custom message extension using Messages SDK and run them on iMessage app store. Before diving in to the project, lets look at the classes provided by Apple for implementation. MSMessagesAppViewController The MSMessagesAppViewController class acts as the principal view controller for Messages extensions. Use this class to manage your extension. MSMessageTemplateLayout The MSMessageTemplateLayout describes how an MSMessage object is presented in the transcript. The message template includes the Message extension’s icon, an image, video, or audio file, and a number of text elements (title, subtitle, captio

Custom sticker extension using Messages SDK - iMessage App store

Image
In our previous article , we discussed about creating basic sticker extension for our iMessage App store. This step requires  to create imgages but no coding effort. Today, in this article we will discuss about creating a custom sticker extension and create stickers from the app. Before diving in to the project, let's have a quick glance about the new classes provided by Apple for implementation. MSMessagesAppViewController The MSMessagesAppViewController class acts as the principal view controller for Messages extensions. Use this class to manage your extension. MSStickerBrowserViewController Use the MSStickerBrowserViewController to present the standard sticker browser. This browser provides drag-and-drop functionality. The user can press and hold a sticker to peel it from the browser, then drag the sticker to any balloon in the transcript. The user can also tap stickers to add them to the Messages app’s input field. MSSticker A sticker for use in the Messages a