Use a better device name for registering push notifications
This commit is contained in:
parent
e882cb6794
commit
f8bcd3d6e0
@ -10,6 +10,7 @@ class PlatformHelper : public QObject
|
||||
Q_PROPERTY(QString deviceSerial READ deviceSerial CONSTANT)
|
||||
Q_PROPERTY(QString deviceModel READ deviceModel CONSTANT)
|
||||
Q_PROPERTY(QString deviceManufacturer READ deviceManufacturer CONSTANT)
|
||||
Q_PROPERTY(QString machineHostname READ machineHostname CONSTANT)
|
||||
|
||||
public:
|
||||
explicit PlatformHelper(QObject *parent = nullptr);
|
||||
@ -18,6 +19,7 @@ public:
|
||||
Q_INVOKABLE virtual void requestPermissions() = 0;
|
||||
|
||||
virtual bool hasPermissions() const = 0;
|
||||
virtual QString machineHostname() const = 0;
|
||||
virtual QString deviceSerial() const = 0;
|
||||
virtual QString deviceModel() const = 0;
|
||||
virtual QString deviceManufacturer() const = 0;
|
||||
|
||||
@ -22,6 +22,12 @@ bool PlatformHelperAndroid::hasPermissions() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PlatformHelperAndroid::machineHostname() const
|
||||
{
|
||||
// QSysInfo::machineHostname always gives "localhost" on android... best we can do here is:
|
||||
return deviceManufacturer() + " " + deviceModel();
|
||||
}
|
||||
|
||||
QString PlatformHelperAndroid::deviceSerial() const
|
||||
{
|
||||
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
|
||||
|
||||
@ -14,6 +14,7 @@ public:
|
||||
Q_INVOKABLE void requestPermissions() override;
|
||||
|
||||
bool hasPermissions() const override;
|
||||
QString machineHostname() const override;
|
||||
QString deviceSerial() const override;
|
||||
QString deviceModel() const override;
|
||||
QString deviceManufacturer() const override;
|
||||
|
||||
@ -15,6 +15,11 @@ bool PlatformHelperGeneric::hasPermissions() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PlatformHelperGeneric::machineHostname() const
|
||||
{
|
||||
return QSysInfo::machineHostName();
|
||||
}
|
||||
|
||||
QString PlatformHelperGeneric::deviceSerial() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
|
||||
@ -13,6 +13,7 @@ public:
|
||||
Q_INVOKABLE virtual void requestPermissions() override;
|
||||
|
||||
virtual bool hasPermissions() const override;
|
||||
virtual QString machineHostname() const override;
|
||||
virtual QString deviceSerial() const override;
|
||||
virtual QString deviceModel() const override;
|
||||
virtual QString deviceManufacturer() const override;
|
||||
|
||||
@ -17,6 +17,11 @@ bool PlatformHelperIOS::hasPermissions() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PlatformHelperIOS::machineHostname() const
|
||||
{
|
||||
return QSysInfo::machineHostName();
|
||||
}
|
||||
|
||||
QString PlatformHelperIOS::deviceSerial() const
|
||||
{
|
||||
// There is no way on iOS to get to a persistent serial number of the device.
|
||||
|
||||
@ -14,6 +14,7 @@ public:
|
||||
Q_INVOKABLE virtual void requestPermissions() override;
|
||||
|
||||
virtual bool hasPermissions() const override;
|
||||
virtual QString machineHostname() const override;
|
||||
virtual QString deviceSerial() const override;
|
||||
virtual QString deviceModel() const override;
|
||||
virtual QString deviceManufacturer() const override;
|
||||
|
||||
@ -157,7 +157,7 @@ Item {
|
||||
PlatformHelper.requestPermissions();
|
||||
}
|
||||
} else {
|
||||
AWSClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.deviceManufacturer + " " + PlatformHelper.deviceModel, PlatformHelper.deviceSerial + "+io.guh.nymeaapp");
|
||||
AWSClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.machineHostname, PlatformHelper.deviceSerial + "+io.guh.nymeaapp");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user