Created
July 13, 2018 09:00
-
-
Save jeluard/2cced0d672039b625e1182eca0672a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var status; | |
window.addEventListener('message', function (event) { | |
if (!event.data || !event.data.type) { return; } | |
if (event.data.type === 'STATUS_API_SUCCESS') { | |
status = event.data.status | |
} | |
}); | |
// request status API | |
window.postMessage({ type: 'STATUS_API_REQUEST', permissions: ["WHISPER"] }); | |
// once approved by user | |
status.whisperKey //available and return data | |
// Other scenario | |
// request status API | |
window.postMessage({ type: 'STATUS_API_REQUEST', permissions: ["WHISPER", "CONTACTS"] }); | |
// user only approves CONTACTS | |
status.whisperKey //either not there or throws | |
status.contacts //available and return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment