{"action":"opened","issue":{"url":"https://api.github.com/repos/NativeScript/sample-android-background-services/issues/3","repository_url":"https://api.github.com/repos/NativeScript/sample-android-background-services","labels_url":"https://api.github.com/repos/NativeScript/sample-android-background-services/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/sample-android-background-services/issues/3/comments","events_url":"https://api.github.com/repos/NativeScript/sample-android-background-services/issues/3/events","html_url":"https://github.com/NativeScript/sample-android-background-services/issues/3","id":179413013,"number":3,"title":"Custom Event fired from NotificationIntentService not get captured","user":{"login":"WinMinTun","id":22287008,"avatar_url":"https://avatars.githubusercontent.com/u/22287008?v=3","gravatar_id":"","url":"https://api.github.com/users/WinMinTun","html_url":"https://github.com/WinMinTun","followers_url":"https://api.github.com/users/WinMinTun/followers","following_url":"https://api.github.com/users/WinMinTun/following{/other_user}","gists_url":"https://api.github.com/users/WinMinTun/gists{/gist_id}","starred_url":"https://api.github.com/users/WinMinTun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WinMinTun/subscriptions","organizations_url":"https://api.github.com/users/WinMinTun/orgs","repos_url":"https://api.github.com/users/WinMinTun/repos","events_url":"https://api.github.com/users/WinMinTun/events{/privacy}","received_events_url":"https://api.github.com/users/WinMinTun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-27T07:07:01Z","updated_at":"2016-09-27T07:07:01Z","closed_at":null,"body":"I wanna update the UI with notification update, and I use custom event. In NotificationIntenetService.js, I emit notification event with data \r\n\r\nandroid.app.IntentService.extend(\"com.nomunoli.notifications.NotificationIntentService\",`\r\n\r\n {\r\n\r\n    onHandleIntent: function (intent) {\r\n        var action = intent.getAction();\r\n        if (\"ACTION_START\" == action) {\r\n            var notiHelper = new NotificationHelper();\r\n            notiHelper.processStartNotification();\r\n        }\r\n\r\n        android.support.v4.content.WakefulBroadcastReceiver.completeWakefulIntent(intent);\r\n    }\r\n});\r\n\r\nvar observableModule = require(\"data/observable\");\r\nvar config = require(\"../../shared/config\");\r\nvar appSettings = require(\"application-settings\");\r\nvar utils = require(\"utils/utils\");\r\nvar app = require('application');\r\n\r\nvar NotificationHelper = (function (_super) {\r\n    __extends(NotificationHelper, _super);\r\n    function NotificationHelper() {\r\n        _super.apply(this, arguments);\r\n    }\r\n    NotificationHelper.prototype.processStartNotification = function () {\r\n\r\n        var _this = this;\r\n\r\n            // fetch notifications\r\n            fetch(config.apiUrlAuth + 'someUrl', {\r\n                method: 'POST'\r\n            }).then(function(response) {\r\n\r\n                if (!response.ok) {\r\n                    throw Error(response.statusText);\r\n                }\r\n\r\n                return response.json();\r\n            }).then(json => {                        \r\n\r\n                // notify the UI about notification\r\n                var eventData = {\r\n                    eventName: \"notificationAll\",\r\n                    object: json\r\n                };\r\n                _this.notify(eventData);\r\n\r\n                var context = utils.ad.getApplicationContext();\r\n                // get app icon\r\n                var resImg = app.android.context.getResources().getIdentifier('icon' , 'drawable', app.android.context.getPackageName());\r\n\r\n                // get notification manager        \r\n                var manager = context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);\r\n\r\n                // notify for each notifications\r\n                json.forEach(function(noti) {\r\n                    \r\n                    var notiId = Math.floor(Math.random()*1000);\r\n                    var builder = new android.app.Notification.Builder(context);\r\n                    builder.setContentTitle(\"NOMUNOLI\")\r\n                        .setAutoCancel(true)\r\n                        .setContentText(noti.userName + noti.message)\r\n                        .setVibrate([100, 200, 100])\r\n                        .setSmallIcon(resImg);\r\n\r\n                    // will open main NativeScript activity when the notification is pressed\r\n                    var mainIntent = new android.content.Intent(context, com.tns.NativeScriptActivity.class);\r\n                    var pendingIntent = android.app.PendingIntent.getActivity(context,\r\n                        1,\r\n                        mainIntent,\r\n                        android.app.PendingIntent.FLAG_UPDATE_CURRENT);\r\n                    builder.setContentIntent(pendingIntent);\r\n                    builder.setDeleteIntent(getDeleteIntent(context));\r\n\r\n                    manager.notify(notiId, builder.build());\r\n                });\r\n                \r\n\r\n            });\r\n\r\n    };\r\n    return NotificationHelper;\r\n})(observableModule.Observable);\r\n\r\nBut the event not get captured in `ViewModel`. Pls kindly help"}}
{"actor":{"display_login":"WinMinTun"}}