Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Created June 14, 2015 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbahrenburg/d74d459fe984c08582fb to your computer and use it in GitHub Desktop.
Save benbahrenburg/d74d459fe984c08582fb to your computer and use it in GitHub Desktop.
Draft API for adding NSUserActivity to Titanium. This allows for the support of hand off, search, etc
var activity = Titanium.App.iOS.createUserActivity({
activityType : "com.appcelerator.handoff.example.browsing-location"
userInfo : someDictionary,
needsSave : false,
webpageUrl : "optional webpage",
title : "an example"
});
activity.addEventListener("useractivitywascontinued",function(e){
console.info(e.activityType);
console.info(e.userInfo);
console.info(e.webpageUrl);
console.info(e.title);
});
//You also have the ability to update those properties created at runtime
activity.setUserInfo(someDictionary); //Update userInfo
activity.setWebpageUrl("some url"); //Update webpageUrl
activity.setTitle("an example title"); //Update title
activity.becomeCurrent(); // creates the NSUserActivity
activity.invalidate(); // make invalid
//For iOS 9
activity.setEligibleForPublicIndexing(true); //A Boolean value that indicates if the activity can be added to a public index that can inform searches by any user of your app on any device.
activity.setEligibleForSearch(true); //A Boolean value that indicates if the activity should be indexed by app history.
activity.setEligibleForHandoff(true); //A Boolean value that indicates if the activity can be handed off to another device using Handoff.
activity.setExpirationDate(new Date(2015,0,1)); //The date after which the activity is no longer eligible to be indexed or handed off.
activity.resignCurrent(); // Tells the activity that it should no longer be the activity currently in use by the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment