Don't let your mobile app get lost - iOS Spotlight and App Indexing

Post on 13-Jan-2017

604 views 1 download

Transcript of Don't let your mobile app get lost - iOS Spotlight and App Indexing

Don't Let Your Mobile App Get Lost

James MontemagnoDeveloper Evangelist, Xamarin

Who’s this guy?

JamesMontemagnoDeveloperEvangelist,Xamarin

james@xamarin.com motzcod.es @JamesMontemagno

Let’s go back to 1997!

• TV: • SouthPark,BuffytheVampireSlayer,&KingoftheHill

• Movies:• StarWarsEpisodeIV- VItheatricalre-releases!• Titanicgrossedover$1billion• StarshipTroopersreleases!

• Games:• FinalFantasyVIIreleases!Sells2Min3days!• GoldenEye 007destroysmychildhood

• Me:• Iturned11!• IgothookedonTamagotchi• IfoundtheInternet!

The Internet in 1997!

App Stores Today

We Apps!

189Mdownloads

a day

200mins on phone

127mins in

apps

How many do we actually use?

The average app user has 36 apps installed on his or her phone.

Only 1/4 are used daily:

1/4 of apps are never used!

My Phone

117 Apps107 “Non-system” Apps!

Used Today

17

Mobile search is a key way for users to discover and engage with your app’s content.

Discover & Engage

SDKs in our toolkit:

• iOS Spotlight Search• Google App Indexing• More:• FacebookAppLinks• TwitterCards• Schema.org Actions• iOSUniversalLinking

iOS Search APIs

NSUserActivity• Handoff Enabled• Pieces of Content

& Pages• When user views• Ability to save

state of screen• Less Data• More Functionality

Core Spotlight• Pre-Indexing Entire

App’s Content• Full set or Part of

set

• More Data • Less Functionality

Web Markup• Deep linking

from web

NSUserActivity: Index Activities

NSUserActivity

• Set “Activity”• Add metadata• Save “Activity”

NSUserActivity CreateActivity(){

var activity = new NSUserActivity("com.xamarin.monkeys.monkey");activity.EligibleForSearch = true;activity.EligibleForPublicIndexing = true;activity.EligibleForHandoff = false;activity.Title = monkey.Name;

activity.Keywords = new NSSet<NSString>(new NSString(monkey.Name),new NSString("Monkey"));

var attributeSet = new CoreSpotlight.CSSearchableItemAttributeSet ();attributeSet.ContentDescription = monkey.Details;activity.ContentAttributeSet = attributeSet;

var info = NSDictionary.FromObjectAndKey(new NSString(monkey.Name),new NSString("Name"));

activity.AddUserInfoEntries(info);

return activity;}

Create Activity

public override void ViewWillAppear(){

base.ViewWillAppear();

UserActivity = CreateActivity();UserActivity.BecomeCurrent();

}

public override void ViewWillDisappear(bool animated){

base.ViewWillDisappear(animated);UserActivity.ResignCurrent();

}

Set Activity

public override void UpdateUserActivityState (NSUserActivity activity){

// update activityvar info = NSDictionary.FromObjectAndKey(new NSString(monkey.Name),

new NSString("Name"));activity.AddUserInfoEntries(info);

base.UpdateUserActivityState (activity);}

Update State

Respondpublic override bool ContinueUserActivity (UIApplication application,

NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler){

// Take action based on the activity typeswitch (userActivity.ActivityType) {

case "com.xamarin.monkeys.monkey":var uid = userActivity.UserInfo.ObjectForKey((NSString)"Name").ToString();

break;}

return true;}

Let’s Search Monkeys!

Google App Indexing

• Put your app in front of users in Google Search

• iOS• Promote Search Results• Deep Link Content• Enhance Display Elements

App Indexing Features•Android• Promote Search Results• Deep Link Content• Enhance Display Elements• Drive Installs: better ranking

signal for all Urls• Query Auto completions • Now on Tap

• In Google SearchSearch Better

• Connect your Site to App

Add support for links (http) and App Indexing API in app

How to index your app

1

2

3

Verify you app against your site on Google Play Developer Console

Publish links (over API)

Add IntentFilter[IntentFilter(new []{ Intent.ActionView },

Categories = new []{

Android.Content.Intent.CategoryDefault,Android.Content.Intent.CategoryBrowsable

},DataScheme = "http",DataHost = "monkeysapp.com",DataPathPrefix ="/Home/Detail/")]

public class MainActivity : BaseActivity{}

Handle Intentprotected override void OnNewIntent(Intent intent){

base.OnNewIntent(intent);var action = intent.Action;var data = intent.DataString;if (Intent.ActionView != action || string.IsNullOrWhiteSpace(data))

return;//only if deep linkingif (!data.Contains("/Home/Detail/"))

return;

var monkeyId = data.Substring(data.LastIndexOf("/", StringComparison.Ordinal) + 1).Replace("%20", " ");

if (!string.IsNullOrWhiteSpace(monkeyId)){

var i = new Intent(this, typeof(DetailsActivity));i.PutExtra("Name", monkeyId);StartActivity(i);

}}

google.com/webmasters

Install App Indexing NuGet

Create “Content Action”GoogleApiClient client;protected override void OnCreate(Android.OS.Bundle savedInstanceState){

base.OnCreate(savedInstanceState);client = new GoogleApiClient.Builder(this).AddApi(AppIndex.API).Build();

}

public IndexingAction AppIndexAction{

get{

var item = new Thing.Builder().SetName(title).SetDescription(description).SetUrl(Android.Net.Uri.Parse(url)).SetType(schemaType).SetId(url).Build();

var thing = new IndexingAction.Builder(IndexingAction.TypeView).SetObject(item).SetActionStatus(IndexingAction.StatusTypeCompleted).Build();

return thing.JavaCast<IndexingAction>();}

Index the Contentprotected override async void OnStart(){

base.OnStart();client.Connect();await AppIndex.AppIndexApi.StartAsync(client, AppIndexAction);

}

protected override async void OnStop(){

base.OnStop();await AppIndex.AppIndexApi.EndAsync(client, AppIndexAction);client.Disconnect();

}

Test Integration in Console

Let’s Search More Monkeys!

iOS 9 App Indexing?

• Simply Add Universal Links (Web Markup)• Integrate Deep Links in ApplicationDelegate• Add app-to-site association in Info.plist• Install App Indexing Component for iOS• Call: GSDAppIndexing.SharedInstance.RegisterApp(“ITUNES_ID”);• DONE!

We can do more!

• Developer Accounts• Google Search• Voice Interactions• App Invites

Developer Accounts

Turn This:

Developer Accounts

Into this:

Google Developer Console

OK Google,

https://blog.xamarin.com/add-a-conversation-to-your-android-app-with-voice-interactions/

Voice Interactions

– Build conversational voice experiences into app

– Extend System Voice Actions– Interact with your users

App Invites– Allow users to share apps– Email or SMS– Deep Link Content– Provide exclusive content

App Invites

Don’t let your app get lost!

• Leverage Search and have your users coming back for more• Connect your website and mobile app for a rich experience• Add unique features to bring more users

Thankyou.

JamesMontemagnoDeveloper Evangelist, Xamarin

james@xamarin.com motzcod.es @JamesMontemagno

slideshare.net/JamesMontemagno