Title: Notifications can't show in my app · Issue #231 · NativeScript/push-plugin · GitHub
Open Graph Title: Notifications can't show in my app · Issue #231 · NativeScript/push-plugin
X Title: Notifications can't show in my app · Issue #231 · NativeScript/push-plugin
Description: I tried this for android, but I can't push notifications in application. My code application, in main-view-model.ts import { Observable } from "tns-core-modules/data/observable"; import * as pushPlugin from "nativescript-push-notificatio...
Open Graph Description: I tried this for android, but I can't push notifications in application. My code application, in main-view-model.ts import { Observable } from "tns-core-modules/data/observable"; import * as pushPl...
X Description: I tried this for android, but I can't push notifications in application. My code application, in main-view-model.ts import { Observable } from "tns-core-modules/data/observable"; impo...
Opengraph URL: https://github.com/NativeScript/push-plugin/issues/231
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Notifications can't show in my app","articleBody":"I tried [this][1] for android, but I can't push notifications in application.\r\n\r\nMy code application,\r\n\r\nin main-view-model.ts\r\n\r\n import { Observable } from \"tns-core-modules/data/observable\";\r\n import * as pushPlugin from \"nativescript-push-notifications\";\r\n export class HelloWorldModel extends Observable {\r\n private pushSettings = {\r\n // Android settings\r\n senderID: \"387819224537\", // Android: Required setting with the sender/project number\r\n notificationCallbackAndroid: (stringifiedData: String, fcmNotification: any) =\u003e {\r\n const notificationBody = fcmNotification \u0026\u0026 fcmNotification.getBody();\r\n console.log(notificationBody)\r\n this.updateMessage(\"Message received!\\n\" + notificationBody + \"\\n\" + stringifiedData);\r\n }\r\n // iOS settings\r\n // badge: true, // Enable setting badge through Push Notification\r\n // sound: true, // Enable playing a sound\r\n // alert: true, // Enable creating a alert\r\n // notificationCallbackIOS: (message: any) =\u003e {\r\n // this.updateMessage(\"Message received!\\n\" + JSON.stringify(message));\r\n // }\r\n };\r\n \r\n private _counter: number;\r\n private _message: string;\r\n \r\n constructor() {\r\n super();\r\n this.message = \"\";\r\n this.updateMessage(\"App started.\");\r\n \r\n let self = this;\r\n this.onRegisterButtonTap();\r\n }\r\n \r\n get message(): string {\r\n return this._message;\r\n }\r\n \r\n set message(value: string) {\r\n if (this._message !== value) {\r\n this._message = value;\r\n this.notifyPropertyChange(\"message\", value);\r\n }\r\n }\r\n \r\n onCheckButtonTap() {\r\n let self = this;\r\n pushPlugin.areNotificationsEnabled((areEnabled: Boolean) =\u003e {\r\n self.updateMessage(\"Are Notifications enabled: \" + !!areEnabled);\r\n });\r\n }\r\n \r\n onRegisterButtonTap() {\r\n let self = this;\r\n pushPlugin.register(this.pushSettings, (token: String) =\u003e {\r\n self.updateMessage(\"Device registered. Access token: \" + token);\r\n // token displayed in console for easier copying and debugging durng development\r\n console.log(\"Device registered. Access token: \" + token);\r\n \r\n if (pushPlugin.registerUserNotificationSettings) {\r\n pushPlugin.registerUserNotificationSettings(() =\u003e {\r\n self.updateMessage(\"Successfully registered for interactive push.\");\r\n }, (err) =\u003e {\r\n self.updateMessage(\"Error registering for interactive push: \" + JSON.stringify(err));\r\n });\r\n }\r\n }, (errorMessage: String) =\u003e {\r\n self.updateMessage(JSON.stringify(errorMessage));\r\n });\r\n }\r\n \r\n onUnregisterButtonTap() {\r\n let self = this;\r\n pushPlugin.unregister(\r\n (successMessage: String) =\u003e {\r\n self.updateMessage(successMessage);\r\n },\r\n (errorMessage: String) =\u003e {\r\n self.updateMessage(JSON.stringify(errorMessage));\r\n },\r\n this.pushSettings\r\n );\r\n }\r\n \r\n private updateMessage(text: String) {\r\n this.message += text + \"\\n\";\r\n }\r\n \r\n }\r\n\r\nin app.ts\r\n\r\n import * as application from 'application';\r\n import firebase = require(\"nativescript-plugin-firebase\");\r\n \r\n firebase.init({\r\n }).then(\r\n (instance) =\u003e {\r\n console.log(\"Fierbase init done!\");\r\n },\r\n (error) =\u003e {\r\n console.log(\"Firebase init error: \" + error);\r\n }\r\n );\r\n \r\n application.run({ moduleName: 'app-root' });\r\n\r\nin main-page.xml\r\n\r\n\t\u003cStackLayout class=\"p-20\"\u003e\r\n\t\t\u003cButton text=\"Are notifications enabled?\" tap=\"{{ onCheckButtonTap }}\" android:visibility=\"collapsed\" class=\"btn\" /\u003e\r\n\t\t\u003cButton text=\"Register device\" tap=\"{{ onRegisterButtonTap }}\" class=\"btn\" /\u003e\r\n\t\t\u003cButton text=\"Unregister device\" tap=\"{{ onUnregisterButtonTap }}\" class=\"btn\" /\u003e\r\n\t\t\u003cLabel text=\"Log:\" class=\"h1\" /\u003e\r\n\t\t\u003cScrollView orientation=\"vertical\"\u003e\r\n\t\t\t\u003cLabel text=\"{{ message }}\" class=\"h2\" textWrap=\"true\" /\u003e\r\n\t\t\u003c/ScrollView\u003e\r\n\t\u003c/StackLayout\u003e\r\n\r\nin mobile show this [![image][2]][2]\r\n\r\nWhen I tried to post from Postman in my app doesn't show any notification. Please can you ask me, who is the problem?\r\n\r\nin Postman I tried like in [![image][3]][3]:\r\n\r\n\r\n [1]: https://market.nativescript.org/plugins/nativescript-push-notifications\r\n [2]: https://i.stack.imgur.com/qauPM.png\r\n [3]: https://i.stack.imgur.com/vQuZw.png","author":{"url":"https://github.com/abinaj","@type":"Person","name":"abinaj"},"datePublished":"2018-07-09T12:34:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/231/push-plugin/issues/231"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:68741cc3-1c28-eb17-5ca1-8f7903aa5476 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E72A:13CA6B:49A957:6093B3:6992144F |
| html-safe-nonce | d0aac0dea1292160480f2ecb1be5058f6dc61af703bd434687ceb7bb1b0d2022 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzJBOjEzQ0E2Qjo0OUE5NTc6NjA5M0IzOjY5OTIxNDRGIiwidmlzaXRvcl9pZCI6IjczNzQ2MjU1OTI1MTg1MTM3NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c9d387dc1a58acb127778a1def1d101c3254b7da1362d82834b9effea3c483d1 |
| hovercard-subject-tag | issue:339430706 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/push-plugin/231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2cbbdb4a56fdac7242f5fc673136567fa2c2a45d99f24a04d600c27b40b24198/NativeScript/push-plugin/issues/231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2cbbdb4a56fdac7242f5fc673136567fa2c2a45d99f24a04d600c27b40b24198/NativeScript/push-plugin/issues/231 |
| og:image:alt | I tried this for android, but I can't push notifications in application. My code application, in main-view-model.ts import { Observable } from "tns-core-modules/data/observable"; import * as pushPl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abinaj |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/push-plugin git https://github.com/NativeScript/push-plugin.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 39781030 |
| octolytics-dimension-repository_nwo | NativeScript/push-plugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 39781030 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/push-plugin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width