TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Custom |
ReleasedLast Release | Dec 2014 |
Maintained by Samir.
iOS 8 has an incredible feature called App Extensions. At Dashlane, we built a powerful and easy-to-implement App Extension for use in your apps. By using the Dashlane App Extension featured in the video above, you will enhance user experience and increase app engagement by eliminating manual data entry in three key areas:
Supporting the Dashlane Extension is similar to general iOS 8 Extension support. A UI element (e.g. a UIButton) needs to be added to trigger a UIActivityViewController instance which is going to present the iOS 8 extension selection UI components. Also, the Dashlane Extension uses NSItemProvider to build the request before passing it to the instance of UIActivityViewController via NSExtensionItem attachments.
DashlaneExtensionRequestHelper is a utility class that can be used to quickly support the Dashlane Extension. It takes care of creating the proper data structure of the request and presenting a UIActivityViewController view on the root view controller of the application key window.
You may want to detect if your app user has Dashlane installed on their iOS device. Using the following code you'll be able to check if an extension ready version of Dashlane is installed:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dashlane-ext://"]) {
// You can attempt to use the Dashlane Extension
}
A request must include a non-empty app name parameter. It is the argument "appName" that needs to be passed to the designated initializer:
- (instancetype)initWithAppName:(NSString *)appName
Without a non-empty app name, the extension will return an error.
A request includes the following steps:
- (void)startNewRequest
- (void)addRequest:(NSString *)requestIdentifier matchingString:(NSString *)stringToMatch
Request identifiers are constants defined by Dashlane to recognize requested data types. To learn more, check DashlaneExtensionConstants.
stringToMatch is used to filter what the extension UI is going to present to the user. Pass nil if you don’t need it.
Multiple data types can be requested using the same request by calling the top methods multiple times for each data type.
- (void)requestLoginAndPasswordWithCompletionBlock:(RequestCompletionBlock)completionBlock
The completion block is the callback that’s going to be called once the extension is dismissed.
A completionBlock is defined as:
typedef void (^RequestCompletionBlock)(NSDictionary *returnedItems, NSError *error);
When the extension is dismissed, the (RequestCompletionBlock) completion block is called with a dictionary representing the answer from the Dashlane Extension. This dictionary contains, for each requested data type (i.e. requestIdentifier), a dictionary representation of a returned user data item. The keys for the dictionary representations of returned user data items can be found in DashlaneExtensionConstants.
Example of a returnedItems dictionary:
{
DASHLANE_EXTENSION_REQUEST_ADDRESS : {DASHLANE_EXTENSION_REQUEST_REPLY_LOGIN_KEY: @“a login”, DASHLANE_EXTENSION_REQUEST_REPLY_PASSWORD_KEY : @“a password"},
DASHLANE_EXTENSION_REQUEST_PHONE_NUMBER : {DASHLANE_EXTENSION_REQUEST_REPLY_PHONE_NUMBER_KEY: @“a phone number"}
}
We hope you’ve found everything you need to get started. If you're interested or have any questions, please email us at [email protected].