|
iOS Invitation Plug-in Tutorial
This page will help you get started with the integration of the AGE invitation plug-in. The plug-in combines the AGE SDK
with a ready-to-use user interface for your iPhone app. The plug-in comes with a customizable tab slide out icon. The icon
is displayed on your app window. Users are able to swipe to open the tab to see suggested friends to invite as well as
inviting friends directly from their address book. Our plug-in supports both landscape and portrait mode apps.
The library only takes minutes to setup, and two lines of code to integrate into your project.
Getting Started
Step 1: Registering your iOS App with Hook Mobile
In order to use the plug-in, you first need to sign up for a free account and register your app with Hook Mobile.
Once you have completed the sign up and registered your account, you must then copy the App Key that is highlighted below in red to setup the library.
Step 2: Install the Invitation Plug-in
Before you begin development, you must have iOS development environment Xcode setup. If you have not downloaded Xcode,
please click on the link below to download Xcode. If you have Xcode set up, please download the AGE Plug-in as listed below.
To install the library, copy all files under the following two folders to your XCode project.
- TabUIExample/SDKClasses
- TabUIExample/TabUI
In addition, the following two folders contain required third party libraries.
Please copy the following files if you do not already have the libraries.
Classes in those third party libraries have been prefixed with the HKM namespace.
They can be safely used even if other frameworks / SDKs in your app use the same libraries.
- TabUIExample/SBJson
- TabUIExample/SVProgressHUD
Finally, you need to add the following iOS SDK frameworks to your project as dependencies:
- AddressBook.framework
- MessageUI.framework
- CoreGraphics.framework
- QuartzCore.framework
- OpenGLES.framework
- libz.dylib
Step 3: Use the Plug-in
To add the tab in your application, add the following lines of code into your app delegate.
- (BOOL)application :(UIApplication *)application didFinishLaunchingWithOptions :(NSDictionary *)launchOptions {
// ... ...
[[HookMainWindow sharedHookMainWindow] initWithWindow:self.window
appKey:@"Your-App-Key"
multiplayer:NO
nativeInvite:YES
requireUserConsent:YES
forceVerificationSms:NO];
hideTab:NO];
// ... ...
}
The Your-App-Key is the app key you created when you first registered for an app on Hook Mobile's web site.
The remaining parameters for the HookMainWindow instance are as follows.
-
nativeInvite - This parameter indicates whether the application should pop up a native SMS composer when the user invites friends.
The native SMS composer allows the invitation message to be sent from the user's own phone number. If the value is set to NO, the invitation SMS
will be sent from Hook Mobile's server side phone number. The invitation will ALWAYS be sent from the Hook Mobile server if the user is on a
non-SMS device, such as an iPod Touch.
-
multiplayer - This parameter indicates whether your application can invite the user's friends to play together in a multi-player mode.
When this parameter is set to YES, you will need to implement the play method in the InstallsController class.
It provides you with a list of friends that user has selected and already have the app installed on their devices.
The logic to setup the multi-player session for your game should be placed in the play method.
-
requireUserConsent - This parameter indicates whether your application needs to ask for user permission before analyzing the address book.
If the user declines to give consent, the AGE SDK will not be able to make recommendations based on the address book.
-
forceVerificationSms - If this parameter is set to YES , the user will not be able to cancel out of the verification SMS composer at the beginning of the app.
This parameter has no effect on non-SMS devices such as iPod Touch and iPad.
-
hideTab - This parameter controls whether the "tab" to the right side of the screen is visible when the slide-out window is closed.
If the tab is hidden, your application needs to call [[HookMainWindow sharedHookMainWindow] iconButtonPress] in order to open the slide-out window.
Customization Options
To customize the user consent text mentioned above, you may modify the text template in HKMConstants.h
You can also choose one from our Sugguested Permission Authorization section.
#define addressbookConsentMsg @"We will scan your address book to identify contacts that you could invite to share the app. Is that okay?"
Furthermore, from the HKMConstants.h file, you can customize the text labels that appear on the tab user interface.
#define inviteTabLabel @"Invite"
#define friendsTabLabel @"Friends"
#define playWithFriendsTabLabel @"Play with Friends"
Auto Rotation
To make the tab rotate with your application, your host view controller needs to support rotation and
call adjustOrientation when it rotates. Due to a bugs in iOS, the adjustOrientation should be called at different points.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return NO;
} else {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
[[HookMainWindow sharedHookMainWindow] adjustOrientation];
}
return YES;
}
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 5.0) {
[[HookMainWindow sharedHookMainWindow] adjustOrientation];
}
}
Ideally, the host application's UIWindow should have a rootViewController.
Without the rootViewController, most of the functionalities of the tab should still work, except for the auto rotation of SMS composer screens.
It is advised not to rotate the device when the SMS composer is present without the rootViewController.
Suggested Permission Authorization (Modify as needed for social, mobile, and non-game apps)
Love our app? Fill from address book and see who can download this cool app.
Love our game? We need to your scan your address book and see who can play too!
Would you like to share our app with your friends? Fill from address book and send them a SMS.
Want to invite more friends to play? Invite from your address book.
Want to invite more friends to play? Fill from your address and send them an invite.
Do you want to share this app with friends? Fill from your address book to invite them.
Fill from your address book to invite your friends!
Do you want to share our app with friends? Send them a message to the app store!
We will scan your address book to identify friends that you could invite to this app. Is this okay?
Would you like to add friends from your address book to download this app?
|