Skip to content

Commit

Permalink
Better handling for exit events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy E. Johansson committed May 20, 2014
1 parent ec5bfa0 commit 8e0f51b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Include `phonegap.userapp.js` after `userapp.client.js`, like this:
<script src="js/phonegap.userapp.js"></script>
```

This will extend the `UserApp` object with the methods `setupPersistentToken(callback)`, `removePersistentToken(callback)` and `oauthHandler(url, callback)`.
This will extend the `UserApp` object with the methods `setupPersistentToken(callback)`, `removePersistentToken(callback)`, and `oauthHandler(url, callback)`.
After a successful login, call `setupPersistentToken()` to create a persistent token and then set the [JavaScript SDK](https://app.userapp.io/#/docs/libs/javascript/) to use that token:

```javascript
Expand Down Expand Up @@ -75,13 +75,15 @@ UserApp.removePersistentToken(function(error) {
});
```

Use the method `oauthHandler()` to open a new browser with an authorization url and then return a persistent token:
Use the method `oauthHandler()` to open a new browser with an authorization url and then return a persistent token. If the token is `null`, the browser was closed.

```javascript
UserApp.OAuth.getAuthorizationUrl({ provider_id: 'facebook' }, function(error, result) {
if (!error) {
UserApp.oauthHandler(result.authorization_url, function(token) {
// the user is logged in with the persistent token 'token'
if (token) {
// the user is logged in with the persistent token 'token'
}
});
}
});
Expand Down
3 changes: 3 additions & 0 deletions phonegap.userapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@
ref.close();
}
});
ref.addEventListener('exit', function() {
callback(null);
});
};
})();

0 comments on commit 8e0f51b

Please sign in to comment.