{"action":"created","issue":{"url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/155","repository_url":"https://api.github.com/repos/driftyco/ionic-cloud-issues","labels_url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/155/comments","events_url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/155/events","html_url":"https://github.com/driftyco/ionic-cloud-issues/issues/155","id":170907690,"number":155,"title":"Ionic push unregister Error","user":{"login":"jgw96","id":8823093,"avatar_url":"https://avatars.githubusercontent.com/u/8823093?v=3","gravatar_id":"","url":"https://api.github.com/users/jgw96","html_url":"https://github.com/jgw96","followers_url":"https://api.github.com/users/jgw96/followers","following_url":"https://api.github.com/users/jgw96/following{/other_user}","gists_url":"https://api.github.com/users/jgw96/gists{/gist_id}","starred_url":"https://api.github.com/users/jgw96/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgw96/subscriptions","organizations_url":"https://api.github.com/users/jgw96/orgs","repos_url":"https://api.github.com/users/jgw96/repos","events_url":"https://api.github.com/users/jgw96/events{/privacy}","received_events_url":"https://api.github.com/users/jgw96/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-12T16:19:26Z","updated_at":"2016-08-12T16:52:51Z","closed_at":"2016-08-12T16:48:16Z","body":"_From @asafco4 on August 12, 2016 7:7_\n\nHi,\r\nIn my app.js, inside of $ionicPlatform.ready, I have:\r\n```\r\nif (ionic.Platform.isAndroid() || ionic.Platform.isIOS()) {\r\n\t\t\r\n\t// Ionic.io push notifications\r\n\tvar push = new Ionic.Push({\r\n\t\t\"debug\": true,\r\n\t\t\"onNotification\": function(notification) {\r\n\t\t\tvar payload = notification.payload;\r\n\t\t\tconsole.log(\"onNotification: \", notification, payload);\r\n\t\t},\r\n\t\t\"onRegister\": function(data) {\r\n\t\t\tconsole.log(\"onRegister: \", data.token);\r\n\t\t}\r\n\t});\r\n\t\t\t\r\n\tvar callback = function(token) {\r\n\t  console.log('Registered token:', token.token);\r\n\t  push.saveToken(token, {'ignore_user': true});\t\t  \r\n\t  $rootScope.notificationsToken = token.token;\r\n\t}\r\n\tpush.register(callback); // End of Ionic.io notifications\r\n\t$window.localStorage.setItem(\"push\", push);\r\n}\r\n```\r\n\r\nWhen a user clicks the logout button, I execute this code:\r\n\r\n```\r\nif (ionic.Platform.isAndroid() || ionic.Platform.isIOS()) {\r\n\tconsole.log(\"logout: Unregister Ionic\");\r\n\tvar push = $window.localStorage.getItem(\"push\");\r\n\tpush.unregister();\r\n\t$window.localStorage.removeItem(\"push\");\r\n\t$window.localStorage.removeItem(\"refer_link\");\r\n}\r\n```\r\n\r\nThat gives me this error:\r\nionic.bundle.min.js:139 TypeError: push.unregister is not a function\r\n\r\nWhy isn't not working? I don't see good example on your documentation...\r\nShould I use object $ionicPush somewhere instead?\r\n\r\nFYI, I don't user the Ionic users, just need to push/token\r\n\r\nThanks!\n\n_Copied from original issue: driftyco/ionic#7678_"},"comment":{"url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/comments/239499584","html_url":"https://github.com/driftyco/ionic-cloud-issues/issues/155#issuecomment-239499584","issue_url":"https://api.github.com/repos/driftyco/ionic-cloud-issues/issues/155","id":239499584,"user":{"login":"asafco4","id":16074756,"avatar_url":"https://avatars.githubusercontent.com/u/16074756?v=3","gravatar_id":"","url":"https://api.github.com/users/asafco4","html_url":"https://github.com/asafco4","followers_url":"https://api.github.com/users/asafco4/followers","following_url":"https://api.github.com/users/asafco4/following{/other_user}","gists_url":"https://api.github.com/users/asafco4/gists{/gist_id}","starred_url":"https://api.github.com/users/asafco4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asafco4/subscriptions","organizations_url":"https://api.github.com/users/asafco4/orgs","repos_url":"https://api.github.com/users/asafco4/repos","events_url":"https://api.github.com/users/asafco4/events{/privacy}","received_events_url":"https://api.github.com/users/asafco4/received_events","type":"User","site_admin":false},"created_at":"2016-08-12T16:52:51Z","updated_at":"2016-08-12T16:52:51Z","body":"Hi, I understand my mistake but how do I fix it?\r\nThe initialization is done in app.js when the app loads, the logout is done on another file.\r\n\r\nshould I store it on $rootScope?\r\ncan I just call: \"var push = new Ionic.Push\" again in the other file and I will get the same instance?\r\n\r\nThanks.\r\n\r\n"}}
{"actor":{"display_login":"asafco4"}}