Skip to content

Instantly share code, notes, and snippets.

@jeluard
Created July 13, 2018 09:00
Show Gist options
  • Save jeluard/2cced0d672039b625e1182eca0672a13 to your computer and use it in GitHub Desktop.
Save jeluard/2cced0d672039b625e1182eca0672a13 to your computer and use it in GitHub Desktop.
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