{"action":"created","issue":{"url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/162","repository_url":"https://api.github.com/repos/myflashlab/Firebase-ANE","labels_url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/162/comments","events_url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/162/events","html_url":"https://github.com/myflashlab/Firebase-ANE/issues/162","id":269794489,"node_id":"MDU6SXNzdWUyNjk3OTQ0ODk=","number":162,"title":"Firebase FCM: \"TOKEN_REFRESH\" event never fired","user":{"login":"tconkling","id":709022,"node_id":"MDQ6VXNlcjcwOTAyMg==","avatar_url":"https://avatars2.githubusercontent.com/u/709022?v=4","gravatar_id":"","url":"https://api.github.com/users/tconkling","html_url":"https://github.com/tconkling","followers_url":"https://api.github.com/users/tconkling/followers","following_url":"https://api.github.com/users/tconkling/following{/other_user}","gists_url":"https://api.github.com/users/tconkling/gists{/gist_id}","starred_url":"https://api.github.com/users/tconkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tconkling/subscriptions","organizations_url":"https://api.github.com/users/tconkling/orgs","repos_url":"https://api.github.com/users/tconkling/repos","events_url":"https://api.github.com/users/tconkling/events{/privacy}","received_events_url":"https://api.github.com/users/tconkling/received_events","type":"User","site_admin":false},"labels":[{"id":486650323,"node_id":"MDU6TGFiZWw0ODY2NTAzMjM=","url":"https://api.github.com/repos/myflashlab/Firebase-ANE/labels/FCM%20ANE","name":"FCM ANE","color":"d4c5f9","default":false},{"id":403127006,"node_id":"MDU6TGFiZWw0MDMxMjcwMDY=","url":"https://api.github.com/repos/myflashlab/Firebase-ANE/labels/Investigating","name":"Investigating","color":"128A0C","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-31T00:14:15Z","updated_at":"2018-08-27T09:53:48Z","closed_at":null,"author_association":"NONE","body":"## Environment ##\r\n* Android API Version: Android 7.0\r\n* iOS Version: n/a\r\n* AIR SDK Version: 27\r\n\r\n## Problem Description ##\r\n\r\nI'm using Firebase FCM. I've been testing uninstalling and re-installing my application (which causes any previously-generated FCM client tokens to be invalidated). Generally, after calling `FCM.init()` on a newly-installed instance of my app, `FCM.getToken()` returns a non-null value. However, in the cases it returns null, `FCM.listener` never fires the `FcmEvents.TOKEN_REFRESH` event.\r\n\r\nQuitting and restarting the app almost always results in it receiving a non-null token.\r\n\r\n* Copy your manifest ```.xml``` file.\r\n```xml\r\n <manifest android:installLocation=\"auto\">\r\n    <uses-permission android:name=\"android.permission.INTERNET\"/>\r\n    <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>\r\n    <uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\r\n\r\n    <!--\r\n        Required by firebase_iid.ane\r\n        Change \"com.versusevil.antihero\" to your own app package name\r\n    -->\r\n    <uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\"/>\r\n    <permission android:name=\"com.versusevil.antihero.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\"/>\r\n    <uses-permission android:name=\"com.versusevil.antihero.permission.C2D_MESSAGE\"/>\r\n\r\n    <application>\r\n\r\n        <activity>\r\n            <intent-filter>\r\n                <action android:name=\"android.intent.action.MAIN\"/>\r\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\r\n            </intent-filter>\r\n            <intent-filter>\r\n                <action android:name=\"android.intent.action.VIEW\"/>\r\n                <category android:name=\"android.intent.category.BROWSABLE\"/>\r\n                <category android:name=\"android.intent.category.DEFAULT\"/>\r\n                <data android:scheme=\"com.versusevil.antihero\" />\r\n            </intent-filter>\r\n        </activity>\r\n\r\n        <!--\r\n            Required by the firebase_common.ane\r\n            Change \"com.versusevil.antihero\" to your own app package name\r\n        -->\r\n        <provider\r\n            android:name=\"com.google.firebase.provider.FirebaseInitProvider\"\r\n            android:authorities=\"com.versusevil.antihero.firebaseinitprovider\"\r\n            android:exported=\"false\"\r\n            android:initOrder=\"100\"/>\r\n        <service\r\n            android:name=\"com.myflashlab.firebase.core.MyFirebaseInstanceIdService\"\r\n            android:exported=\"true\">\r\n            <intent-filter>\r\n                <action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>\r\n            </intent-filter>\r\n        </service>\r\n\r\n        <!-- Required by googlePlayServices_basement.ane -->\r\n        <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\"/>\r\n\r\n        <!--\r\n            Required by firebase_iid.ane\r\n            Change \"com.versusevil.antihero\" to your own app package name\r\n        -->\r\n        <receiver\r\n            android:name=\"com.google.firebase.iid.FirebaseInstanceIdReceiver\"\r\n            android:exported=\"true\"\r\n            android:permission=\"com.google.android.c2dm.permission.SEND\">\r\n            <intent-filter>\r\n                <action android:name=\"com.google.android.c2dm.intent.RECEIVE\"/>\r\n                <category android:name=\"com.versusevil.antihero\"/>\r\n            </intent-filter>\r\n        </receiver>\r\n        <receiver\r\n            android:name=\"com.google.firebase.iid.FirebaseInstanceIdInternalReceiver\"\r\n            android:exported=\"false\"/>\r\n        <service\r\n            android:name=\"com.google.firebase.iid.FirebaseInstanceIdService\"\r\n            android:exported=\"true\">\r\n            <intent-filter android:priority=\"-500\">\r\n                <action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>\r\n            </intent-filter>\r\n        </service>\r\n\r\n        <!-- Required by googlePlayServices_base.ane -->\r\n        <activity android:name=\"com.google.android.gms.common.api.GoogleApiActivity\"\r\n            android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\r\n            android:exported=\"false\"/>\r\n        <!-- Required by firebase_messaging.ane -->\r\n        <service android:name=\"com.myflashlab.firebase.fcm.MyFirebaseMessagingService\">\r\n            <intent-filter>\r\n                <action android:name=\"com.google.firebase.MESSAGING_EVENT\"/>\r\n            </intent-filter>\r\n        </service>\r\n        <service android:name=\"com.myflashlab.firebase.fcm.MyFirebaseInstanceIDService\">\r\n            <intent-filter>\r\n                <action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>\r\n            </intent-filter>\r\n        </service>\r\n        <activity\r\n            android:name=\"com.myflashlab.firebase.fcm.MyFirebaseMessagingIntent\"\r\n            android:theme=\"@style/Theme.Transparent\"\r\n            android:exported=\"false\"\r\n            android:noHistory=\"true\"\r\n            android:clearTaskOnLaunch=\"true\"\r\n            android:hardwareAccelerated=\"false\"\r\n            android:stateNotNeeded=\"true\">\r\n            <intent-filter>\r\n                <action android:name=\"MY_INTENT\" />\r\n                <category android:name=\"android.intent.category.DEFAULT\" />\r\n            </intent-filter>\r\n        </activity>\r\n\r\n    </application>\r\n</manifest>\r\n```\r\n* Copy your Actionscript code.\r\n```actionscript\r\n   private function initFCM () :void {\r\n        // FCM.listener is null before this point\r\n        FCM.init();\r\n        _initialized = true;\r\n\r\n        var self :FirebasePushNotifications = this;\r\n        _regs.addEventListener(FCM.listener, FcmEvents.TOKEN_REFRESH, function (e :FcmEvents) :void {\r\n            // THIS EVENT HANDLER IS NEVER CALLED\r\n            log.info(\"Token refresh\");\r\n            self.token.value = e.token;\r\n        });\r\n\r\n        _regs.addEventListener(FCM.listener, FcmEvents.MESSAGE, onMessageReceived);\r\n\r\n        _regs.addEventListener(FCM.listener, FcmEvents.ERROR, function (e :FcmEvents) :void {\r\n            log.warning(\"FCM error: \" + e.msg);\r\n        });\r\n\r\n        var initialToken :String = FCM.getToken();\r\n        if (initialToken == null) {\r\n            log.info(\"FCM token is null\");\r\n        }\r\n        this.token.value = initialToken;\r\n\r\n        if (_pendingInvokeEvent != null) {\r\n            handleInvokeEvent(_pendingInvokeEvent);\r\n            _pendingInvokeEvent = null;\r\n        }\r\n    }\r\n```\r\n\r\n## Steps to Reproduce ##\r\n\r\nUninstall and re-install an FCM-enabled app. Launch it. Some of the time (~25%, in my anecdotal experience?), `FCM.getToken()` will return null after FCM initialization. The expected behavior in this instance is that `FCM.listener` will dispatch a `FcmEvents.TOKEN_REFRESH` event at some point in the future, but this never happens."},"comment":{"url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/comments/416176315","html_url":"https://github.com/myflashlab/Firebase-ANE/issues/162#issuecomment-416176315","issue_url":"https://api.github.com/repos/myflashlab/Firebase-ANE/issues/162","id":416176315,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjE3NjMxNQ==","user":{"login":"chpla","id":20185592,"node_id":"MDQ6VXNlcjIwMTg1NTky","avatar_url":"https://avatars2.githubusercontent.com/u/20185592?v=4","gravatar_id":"","url":"https://api.github.com/users/chpla","html_url":"https://github.com/chpla","followers_url":"https://api.github.com/users/chpla/followers","following_url":"https://api.github.com/users/chpla/following{/other_user}","gists_url":"https://api.github.com/users/chpla/gists{/gist_id}","starred_url":"https://api.github.com/users/chpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chpla/subscriptions","organizations_url":"https://api.github.com/users/chpla/orgs","repos_url":"https://api.github.com/users/chpla/repos","events_url":"https://api.github.com/users/chpla/events{/privacy}","received_events_url":"https://api.github.com/users/chpla/received_events","type":"User","site_admin":false},"created_at":"2018-08-27T09:53:48Z","updated_at":"2018-08-27T09:53:48Z","author_association":"NONE","body":"Did the iid test, initially after install of the app, the returned iid is null. After requesting the push token, the onIdeReceived handler is called and an iid is returned. But an id token event is never fired, nor is the push token event."}}
{"actor":{"display_login":"chpla"}}