Skip to content

Instantly share code, notes, and snippets.

@drewlarsen
drewlarsen / sugarwod.java
Last active April 26, 2019 18:30
How to Open SugarWOD from another Android App
// Adapted from:
// https://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent/7596063#7596063
/** Open SugarWOD.
* @param context current Context, like Activity, App, or Service
* @return true if likely successful, false if unsuccessful
*/
public static boolean openSugarWOD(Context context) {
String packageName = "com.flatironssoftware.sugarwod";
PackageManager manager = context.getPackageManager();
@drewlarsen
drewlarsen / sugarwod.m
Created February 1, 2018 15:32
How to Open SugarWOD from another iOS App
// Sample code to open the SugarWOD iOS app from another app
// will attempt to open the app,
// if app is not installed,
// will re-direct to the SugarWOD page in the app store or in Safari
// SugarWOD URL Scheme
NSURL *url = [NSURL URLWithString:@"sugarwod://"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
// open sugarwod app
@drewlarsen
drewlarsen / gist:2fbf0c93e990dbe8848e028b861fac2d
Created November 10, 2016 16:35
Sample code to open the SugarWOD iOS app with the URL Link Scheme
#pragma mark URL SCHEME TESTING
- (IBAction)launchButtonTouchUpInside:(UIButton *)sender {
// Sample code to open the SugarWOD iOS app from another app
// will attempt to open the app,
// if app is not installed,
// will re-direct to the SugarWOD page in the app store or in Safari
// SugarWOD URL Scheme
NSURL *url = [NSURL URLWithString:@"sugarwod://"];
@drewlarsen
drewlarsen / promises-with-validations.js
Last active July 23, 2017 11:51
A pattern for a Parse.com Cloud Code function using Promises, including validations, fetches, saves.
// A cloud Code function that is called from iOS, Android and web
// each time an athlete logs into the app
// Updates the athlete and creates an entry in the "TB_Login" class
// NOTE: isDefined is a utility function defined elsewhere
Parse.Cloud.define("athleteDidLogin", function(request, response) {
// req'd params
var athId = request.params.athId;