Skip to content

Instantly share code, notes, and snippets.

module.exports = function(original_url, branch_base_url) {
if (!original_url) { return new Error('Missing original_url'); }
if (typeof original_url != 'string') { return new Error('Invalid original_url'); }
if (!branch_base_url) { return new Error('Missing branch_base_url, should be similar to https://bnc.lt/abcd/3p?%243p=xx'); }
if (typeof branch_base_url != 'string') { return new Error('Invalid branch_base_url'); }
return branch_base_url + '&%24original_url=' + encodeURIComponent(original_url);
};
var crypto = require('crypto');
module.exports = function(original_url, branch_base_url, branch_hmac_secret, three_p_url) {
if (!original_url) { return new Error('Missing original_url'); }
if (typeof original_url != 'string') { return new Error('Invalid original_url'); }
if (!branch_base_url) { return new Error('Missing branch_base_url, should be similar to https://bnc.lt/abcd/3p?%243p=xx'); }
if (typeof branch_base_url != 'string') { return new Error('Invalid branch_base_url'); }
if (!branch_hmac_secret) { return new Error('Missing branch_hmac_secret'); }
if (typeof branch_hmac_secret != 'string') { return new Error('Invalid branch_hmac_secret'); }
if (three_p_url && typeof three_p_url != 'string') { return new Error('Invalid three_p_url'); }
// 1. Get list of previous contacts from NSUserDefaults
NSMutableArray *previousContacts =
[[[NSUserDefaults standardUserDefaults] objectForKey:@"contacts"] mutableCopy];
if (!previousContacts) previousContacts = [NSMutableArray array];
// 2. Add new contact to list
self.url = [[Branch getInstance] getShortURLWithParams:@{@"email": self.emailTextField.text}]; // [see note 2]
NSDictionary *newContact = @{ @"name": self.nameTextField.text,
@"email": self.emailTextField.text,
@"company": self.companyTextField.text,
@derrick-branch
derrick-branch / ViewController.m
Created July 22, 2015 19:34
MFMailComposeViewController
// At top of ViewController implementation
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface ViewController () <MFMailComposeViewControllerDelegate>
@end
@implementation ViewController
- (void)sendEmail {