diff --git a/nymea-app/pushnotifications.cpp b/nymea-app/pushnotifications.cpp index 610c9701..ce1ea847 100644 --- a/nymea-app/pushnotifications.cpp +++ b/nymea-app/pushnotifications.cpp @@ -64,6 +64,7 @@ QString PushNotifications::token() const void PushNotifications::setAPNSRegistrationToken(const QString &apnsRegistrationToken) { + qDebug() << "Received APNS push notification token:" << apnsRegistrationToken; m_token = apnsRegistrationToken; emit tokenChanged(); } diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index 629dbc32..17876859 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -61,6 +61,13 @@ ApplicationWindow { setupPushNotifications(false) } } + Connections { + target: PushNotifications + onTokenChanged: { + setupPushNotifications(); + } + } + Connections { target: Engine.awsClient onIsLoggedInChanged: { @@ -133,14 +140,22 @@ ApplicationWindow { askForPermissions = true; } - if (Engine.awsClient.isLoggedIn) { - if (!PlatformHelper.hasPermissions) { - if (askForPermissions) { - PlatformHelper.requestPermissions(); - } - } else { - Engine.awsClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.deviceManufacturer + " " + PlatformHelper.deviceModel, PlatformHelper.deviceSerial); + if (!Engine.awsClient.isLoggedIn) { + print("AWS not logged in. Cannot register for push"); + return; + } + + if (PushNotifications.token.length === 0) { + print("Don't have a token yet. Cannot register for push"); + return; + } + + if (!PlatformHelper.hasPermissions) { + if (askForPermissions) { + PlatformHelper.requestPermissions(); } + } else { + Engine.awsClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.deviceManufacturer + " " + PlatformHelper.deviceModel, PlatformHelper.deviceSerial); } } diff --git a/packaging/android/notificationicon.svg b/packaging/android/notificationicon.svg index 10b9b96a..adb5fb2b 100644 --- a/packaging/android/notificationicon.svg +++ b/packaging/android/notificationicon.svg @@ -14,7 +14,7 @@ id="svg2" version="1.1" inkscape:version="0.92.3 (2405546, 2018-03-11)" - sodipodi:docname="notificationicon2.svg" + sodipodi:docname="notificationicon.svg" inkscape:export-filename="/home/micha/Develop/nymea-app/packaging/android/res/drawable-mdpi/notifiyicon.png" inkscape:export-xdpi="9" inkscape:export-ydpi="9"> @@ -439,7 +439,7 @@ id="path2390" transform="translate(143.41788,709.27353)" /> @@ -499,7 +499,7 @@ id="path2366" transform="translate(143.41788,709.27353)" /> @@ -539,7 +539,7 @@ id="path2350" transform="translate(143.41788,709.27353)" /> @@ -549,7 +549,7 @@ id="path2346" transform="translate(143.41788,709.27353)" /> @@ -634,7 +634,7 @@ id="path2312" transform="translate(143.41788,709.27353)" /> @@ -644,7 +644,7 @@ id="path2308" transform="translate(143.41788,709.27353)" /> @@ -664,7 +664,7 @@ id="path2300" transform="translate(143.41788,709.27353)" /> @@ -719,12 +719,12 @@ id="path2278" transform="translate(143.41788,709.27353)" /> @@ -734,15 +734,10 @@ id="path2272" transform="translate(143.41788,709.27353)" /> -