Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leaysgur/app-opener
Better way to open native app from your mobile web site.
https://github.com/leaysgur/app-opener
Last synced: 9 days ago
JSON representation
Better way to open native app from your mobile web site.
- Host: GitHub
- URL: https://github.com/leaysgur/app-opener
- Owner: leaysgur
- License: mit
- Created: 2015-04-11T06:42:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-27T11:35:14.000Z (over 9 years ago)
- Last Synced: 2024-10-14T19:14:57.718Z (23 days ago)
- Language: JavaScript
- Homepage: http://labs.lealog.net/app-opener-sample/
- Size: 246 KB
- Stars: 36
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# app-opener
Better way to open native app from your mobile web site.## How to use
### index.html
```html
Share to Twitter
```Be careful NOT to set ``target="_blank"``.
### share-tw.html
```html
Share to Twitter appvar isAndroid = navigator.userAgent.toLowerCase().indexOf('android') !== -1;
var shareText = encodeURIComponent('Webからアプリが開いたよ!! @leader22++ https://github.com/leader22/app-opener') + ' ';
var schemeStr = (isAndroid) ? 'intent://post?message=' + shareText + '#Intent;scheme=twitter;package=com.twitter.android;end;'
: 'twitter://post?message=' + shareText;
new AppOpener({
schemeStr: schemeStr,
escapeUrl: 'index.html'
});```
## Options
### options.schemeStr
[Required] {String} Uri scheme strings you want to open.### options.escapeUrl
[Required] {String} Url to escape at after app opened or invalid situation.### options.androidSlowestAppBootTime
[Default] 500
[options] {Number} The time that it takes for the app to boot completely.### options.iOSFastestAppBootTime
[Default] 20
[options] {Number} The time that it takes for the app to start boot.### options.iOSNotInstalledFunc
[Default] alert('See code ;o')
[options] {Function} Executed at app could not boot on iOS.Please try [demo](http://labs.lealog.net/app-opener-sample/).
## Scheme example
```javascript
const SCHEME = {
TWITTER: {
SHARE: {
IOS: 'twitter://post?message={{TEXT}}',
ANDROID: 'intent://post?message={{TEXT}}#Intent;scheme=twitter;package=com.twitter.android;end;'
},
SHOW_PROFILE: {
IOS: 'twitter://user?screen_name={{SCREEN_NAME}}',
ANDROID: 'intent://user?screen_name={{SCREEN_NAME}}#Intent;scheme=twitter;package=com.twitter.android;end;'
}
},
FACEBOOK: {
SHARE: {
// 探せば見つかるかもしれないが私はココロが折れました
// そしてコレがないのは中々に辛い
},
SHOW_PROFILE: {
IOS: 'fb://profile/{{USER_ID}}',
ANDROID: ''
}
},
LINE: {
SHARE: {
IOS: 'line://msg/text/{{TEXT}}',
ANDROID: 'intent://msg/text/{{TEXT}}#Intent;scheme=line;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;package=jp.naver.line.android;end;'
},
ADD_FRIEND: {
IOS: 'line://ti/p/{{USER_ID}}',
ANDROID: 'intent://ti/p/{{USER_ID}}#Intent;scheme=line;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;package=jp.naver.line.android;end;'
}
}
}
```