dispatch:short-url
Create short urls, supports android and ios intents / custom-url shemes.
Usage examples
1 // Setup a url shortner 2 shortUrl = new UrlShortner({ 3 prefix: '/s' // If the shortner is to co-exist with 4 // the application then prefix, default is /s/XXXXXXXX 5 // rateLimit: { // Set rate limit options on the http point 6 // totalRequests: 10, 7 // every: 60000 8 // }, 9 fallbackUrl: 'https://go.to.here.if.the.redirect.fails', 10 // debug: true // Make it verbose 11 }); 12 13 // Create a short url 14 shortUrl = createShortUrl('https://if.this.is.a.long.url.then.shorten.me'); 15 16 // Create a short url for android and iOS 17 // Note: Provide the android fallback url in the intent for the best 18 // user experience 19 shortUrl = createShortUrl('https://if.this.is.a.long.url.then.shorten.me', { 20 androidUrl: 'intent://?platform=android#Intent;scheme=dispatchdeeplinktest;'+ 21 'package=me.dispatch.qa.test.deep.link;' + 22 'S.browser_fallback_url=http://www.google.com;end', 23 iosUrl: 'dispatchdeeplinktest://?shorturl=ios' 24 }); 25 26 // Limit usage 27 shortUrl = createShortUrl('https://if.this.is.a.long.url.then.shorten.me', { 28 expireAt=10000 + new Date(), // Set expiration time/date 29 oneTimeLink=false // Set true and this link will only work once 30 });
dispatch:deep-link example
1 // Add the "dispatch:deep-link" package 2 // Initialize the deepLink - customURL scheme 3 deepLink = new DeepLink('dispatchdeeplinktest', { 4 fallbackUrl: 'https:/go.to.here.if.the.redirect.fails', // Adding a fallback here will add it to the android intent 5 appId: 'me.dispatch.qa.test.deep.link' 6 }); 7 8 // Setup a url shortner 9 shortUrl = new UrlShortner({ 10 prefix: '/s', 11 fallbackUrl: 'https://go.to.here.if.the.redirect.fails', 12 }); 13 14 // Create some data to send 15 var payload = { 16 foo: 'bar', 17 createdAt: new Date() // Supports EJSON 18 bar: { // and 19 foo: 'bar2' // Nested data 20 } 21 }; 22 23 // Create the shortUrl 24 shortUrl = createShortUrl('https://if.this.is.a.long.url.then.shorten.me', { 25 androidUrl: deepLink.androidLink('', payload), 26 iosUrl: deepLink.iosLink('', payload) 27 });