In-Game Linking Getting Started Guide - PlayHaven Blog

tibburfrogtownΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

73 εμφανίσεις

Increase Engagement and Awareness.
IN-GAME LINKING
Contact your account manager for more info: publish@playhaven.com I www.playhaven.com
Did you know that you can send players to a specific location in your game after they click on PlayHaven
Announcements? It’s true. With in-game linking, you can direct segments of your players to specific
destinations in your game that are highly relevant to their experience - thereby increasing player
engagement and awareness.
Use Cases:
We’ve provided some interesting ways our developers are utilizing in-game linking but don’t feel restricted
by these suggestions. What works for your game?
Create a new Announcement, target a player segment and then simply:
• Link to your store when new items are listed, new discounts, or carts abandoned
• Link to leaderboards
• Link to a specific level in your game
• Link to your game e-mail/inbox system
• Link to a secret store for whales or newbies or minnows
• Link to a secret spot in your game like access to a free bonus
• Link to a bonus round (You've been great, check out this bonus round)
• Link to a different mode of play
• Hey, you've played single player, try out multiplayer here!
• Or in a Casino game, you've tried blackjack, now try our poker game!
• Link to a users profile or settings (Hey, customize your profile, click here!)
• Link to gift center (Send a gift to your friends!)
• Link to a tutorial (Forgot how to play, check out the tutorial!)
IN-GAME LINKING
Contact your account manager for more info: publish@playhaven.com I www.playhaven.com
Ensuring your game can support in-game linking
Now that you’re interested in further increasing player engagement and awareness with in-game
linking, let’s make sure your game is set up properly to support in-game linking.
You may send players to a specific destination in your game once they click on an Announcement.
It is up to you to code your app so that it can handle this URL. To do so, follow the instructions
provided by Apple in Implementing Custom URL Schemes section of iOS App Programming
Guide. Here is a quick step-by-step guide on how to do a very simple implementation of this. First,
you need to register your URL scheme in your application’s info.plist file:
Click your Info.plist file in your Xcode project. (It will appear as “YourAppName-Info.plist” in the
Resources folder.)
1. Right-click the top level “Information Property List” and select “Add Row”.
2. From the drop-down list, select “URL Types” as the key.
3. Expand the “URL types” key you just created to show “Item 0”.
4. Expand the “Item 0” key to show the key “URL Identifier”.
5. Edit the value of “URL Identifier” to some value. The convention is to use a reverse
domain name, such as “com.mydomain.myapp” (Don’t actually use the quotation marks.).
6. Add a row to “Item 0”.
7. From the drop-down list, select “URL Schemes” as the key.
8. Edit the value of “Item 0” under “URL Schemes” to be the URL scheme you want (e.g.
“myapplication”). This will be the name by which other applications can launch your
application.
iOS:
If you prefer, you can instead edit the info.plist file in a text editor, and add the following block of
text after the first <dict> tag. Be sure to replace “myapplication” and “com.mydomain.myapp” with
values appropriate for your own application:
You may send players to a specific destination in your game once they click on an Announcement.
It is up to you to code your app so that it can handle this URL. To do so, follow the instructions
provided by Apple in Implementing Custom URL Schemes section of iOS App Programming
Guide. Here is a quick step-by-step guide on how to do a very simple implementation of this. First,
you need to register your URL scheme in your application’s info.plist file:
Click your Info.plist file in your Xcode project. (It will appear as “YourAppName-Info.plist” in the
Resources folder.)
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapplication</string>
</array>
<key>CFBundleURLName</key>
<string>com.mydomain.myapp</string>
</dict>
</array>
You can test whether or not you have done your URL Scheme registration correctly by installing
your app on a device or simulator, opening Safari, and typing “myapplication:” (i.e. whatever URL
scheme you chose, followed by a ‘:’) into the browser address window. If you registered your URL
scheme correctly, this should launch your app.
Your app also needs to be able to handle the custom URL’s passed to it by the PlayHaven platform.
There are numerous ways to do this. One way is to add a application:
openURL:sourceApplication:annotation: method to your AppDelegate.m file, like this:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString
*)sourceApplication annotation:(id)annotation
{
NSLog(@"This app was launched with this URL: %@", url.absoluteString);
//code to take action based on the URL would go here
//for example, if opened with URI myapplication://openthestore, then we open the store
if ([url.absoluteString isEqualToString:@"myapplication://openthestore"])
{
NSLog(@"Opening the store...");
// Code to open the store goes here
}
return YES;
}
For more information on how to handle custom URL Schemes, please see Apple’s documentation
on implementing custom URL schemes.
IN-GAME LINKING
Contact your account manager for more info: publish@playhaven.com I www.playhaven.com
IN-GAME LINKING
Contact your account manager for more info: publish@playhaven.com I www.playhaven.com
Android:
PlayHaven’s Business Engine allows you to pass a custom URI location to send the user to, for
example, your In App Purchase store. You'll need to implement a Receiver (and declare it in your
Manifest) in order to handle custom URIs on your own. Below is an example of an application
getting a custom number of Easter Eggs, silently, from a push notification.
First, you have add the following to the manifest:
AndroidManifest.xml
<!-- This receives a custom URI broadcast from the PlayHaven SDK. -->
<receiver android:name="com.playhaven.android.breweryblocks.CustomReceiver">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="bb" android:host="com.playhaven.android.breweryblocks"/>
</intent-filter>
</receiver>
Next, you create the following class:
CustomReceiver.java
public class CustomReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Here is where you would put code to do whatever you want - open a part of the game, etc etc
Log.v("BreweryBlocks", "This many eggs: " + intent.getData().getQueryParameter("east-
erEggs"));
}
}
IN-GAME LINKING
Contact your account manager for more info: publish@playhaven.com I www.playhaven.com
Lastly, you have to pass the following JSON (Select `JSON` in the Message section for your push
in the Dashboard):
{
"TITLE": " More Eggs",
"URI": "bb://com.playhaven.android.breweryblocks?easterEggs=15",
"TEXT": "You’ve receive more eggs "
}
The ADB logs:
V/BreweryBlocks(11583): This many eggs: 15
Tip:
One very important thing to remember about BroadcastReceiver is that it won't, on its own,
run in its own thread. Network requests and other long-running tasks should be handled with
appropriate processes and threads to avoid ANR and other errors.
Example:
"bb://com.playhaven.android.breweryblocks?easterEggs=15