{"action":"created","issue":{"url":"https://api.github.com/repos/intercom/intercom-cordova/issues/18","labels_url":"https://api.github.com/repos/intercom/intercom-cordova/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/intercom/intercom-cordova/issues/18/comments","events_url":"https://api.github.com/repos/intercom/intercom-cordova/issues/18/events","html_url":"https://github.com/intercom/intercom-cordova/issues/18","id":104702951,"number":18,"title":"Android - Intercom widget should never be shawn before deviceReady has ended","user":{"login":"slorber","id":749374,"avatar_url":"https://avatars.githubusercontent.com/u/749374?v=3","gravatar_id":"","url":"https://api.github.com/users/slorber","html_url":"https://github.com/slorber","followers_url":"https://api.github.com/users/slorber/followers","following_url":"https://api.github.com/users/slorber/following{/other_user}","gists_url":"https://api.github.com/users/slorber/gists{/gist_id}","starred_url":"https://api.github.com/users/slorber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slorber/subscriptions","organizations_url":"https://api.github.com/users/slorber/orgs","repos_url":"https://api.github.com/users/slorber/repos","events_url":"https://api.github.com/users/slorber/events{/privacy}","received_events_url":"https://api.github.com/users/slorber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-09-03T14:07:16Z","updated_at":"2015-09-04T09:18:30Z","closed_at":null,"body":"It may apply to iOS too but I don't have any iPhone to test\r\n\r\n--------------------------------------\r\n\r\n# Summary\r\n\r\nWhen the app is starting in a logged out state: it may, at the very beginning, show the intercom widget that corresponds to the last connected user (instead of showing nothing)\r\n\r\nWhen a logged in user kills the application (or the application crash) and restarts it in logged-out state, there's a small amount of time where the intercom widget may be shawn.\r\nIn my case it is even shawn on top of the Splash Screen, before the onDeviceReady event gets fired (because my JS takes some time to parse)\r\n\r\n\r\n\r\n---------------------------------\r\n\r\n# Full\r\n\r\nI have an app with a login screen, and only logged-in user.\r\nI mean I don't use `intercom.registerUnidentifiedUser()` because the logged-out part is very small.\r\n\r\nThe user may or not want to keep being logged in on app restart (ie a checkbox \"remember me\" option during login).\r\n\r\nWhen the user log in, I call `intercom.registerIdentifiedUser(intercomData);`\r\n\r\n\r\nMy app startup pseudo-code looks like this:\r\n\r\n```javascript\r\nfunction deviceReady() {\r\n    hideSplashScreen();\r\n    if ( autoConnectUser ) {\r\n        intercom.registerIdentifiedUser(userIntercomData);\r\n        startApp();\r\n    } \r\n    else {\r\n        intercom.reset();\r\n        showLoginForm();\r\n    }\r\n}\r\n```\r\nMy JS application is heavy. The parsing of the JS files on a bad device can take something like 3 seconds.\r\n\r\nWhen the app is killed, it seems the intercom registered user is not removed (probably on purpose).\r\n\r\nWhen the app is restarted in logged out state (because the user did not check the \"remember me\" checkbox), then there's a small amount of time where the intercom widget shows up, and then it is removed (because my `deviceReady` call `reset()`). This somehow corresponds to the time my JS takes to be parsed, and the widget appears on top of the splash screen.\r\n\r\nI think the intercom plugin should never display the widget before the deviceReady function has ended, giving the oppurtunity to the developer to handle \"implicit logouts\" that can be caused by application being killed, application crash... (we can't listen for kill/crash events)\r\n\r\nAlso I'm not sure if it's worth to allow the intercom widget to be shawn on top of the splash screen.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/intercom/intercom-cordova/issues/comments/137686181","html_url":"https://github.com/intercom/intercom-cordova/issues/18#issuecomment-137686181","issue_url":"https://api.github.com/repos/intercom/intercom-cordova/issues/18","id":137686181,"user":{"login":"slorber","id":749374,"avatar_url":"https://avatars.githubusercontent.com/u/749374?v=3","gravatar_id":"","url":"https://api.github.com/users/slorber","html_url":"https://github.com/slorber","followers_url":"https://api.github.com/users/slorber/followers","following_url":"https://api.github.com/users/slorber/following{/other_user}","gists_url":"https://api.github.com/users/slorber/gists{/gist_id}","starred_url":"https://api.github.com/users/slorber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slorber/subscriptions","organizations_url":"https://api.github.com/users/slorber/orgs","repos_url":"https://api.github.com/users/slorber/repos","events_url":"https://api.github.com/users/slorber/events{/privacy}","received_events_url":"https://api.github.com/users/slorber/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T09:18:30Z","updated_at":"2015-09-04T09:18:30Z","body":" @jtreanor yes I tried it and it seems I did not get the intercom widget running after ondeviceready but only after going in background and resuming, which is still not good. However I'm not sure my test was correct as I'm not very confortable how to monkeypatch cordova plugins right now :)"}}