PRovide required data for bulk push notifications
This commit is contained in:
parent
a0834a0dc6
commit
58eb43b2b9
@ -603,7 +603,7 @@ void AWSClient::getId()
|
||||
});
|
||||
}
|
||||
|
||||
void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId, const QString &deviceDisplayName, const QString mobileDeviceId)
|
||||
void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId, const QString &deviceDisplayName, const QString mobileDeviceId, const QString &mobileDeviceManufacturer, const QString &mobileDeviceModel)
|
||||
{
|
||||
if (!isLoggedIn()) {
|
||||
qWarning() << "Not logged in at AWS. Can't register push endpoint";
|
||||
@ -611,7 +611,7 @@ void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId,
|
||||
}
|
||||
if (tokensExpired()) {
|
||||
qDebug() << "Cannot register push endpoint. Need to refresh our tokens";
|
||||
QueuedCall::enqueue(m_callQueue, QueuedCall("registerPushNotificationEndpoint", registrationId, deviceDisplayName, mobileDeviceId));
|
||||
QueuedCall::enqueue(m_callQueue, QueuedCall("registerPushNotificationEndpoint", registrationId, deviceDisplayName, mobileDeviceId, mobileDeviceManufacturer, mobileDeviceModel));
|
||||
refreshAccessToken();
|
||||
return;
|
||||
}
|
||||
@ -627,6 +627,14 @@ void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId,
|
||||
payload.insert("channel", m_configs.value(m_usedConfig).pushNotificationSystem);
|
||||
payload.insert("mobileDeviceDisplayName", deviceDisplayName);
|
||||
payload.insert("mobileDeviceUuid", mobileDeviceId);
|
||||
payload.insert("mobileDeviceManufacturer", mobileDeviceManufacturer);
|
||||
payload.insert("mobileDeviceModel", mobileDeviceModel);
|
||||
payload.insert("appVersion", APP_VERSION);
|
||||
payload.insert("marketResearchAllowed", false);
|
||||
payload.insert("locale", QLocale().name());
|
||||
payload.insert("platform", QSysInfo::productType());
|
||||
payload.insert("platformVersion", QSysInfo::productVersion());
|
||||
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload);
|
||||
|
||||
qDebug() << "Registering push notification endpoint" << mobileDeviceId;
|
||||
@ -815,7 +823,7 @@ void AWSClient::getCredentialsForIdentity(const QString &identityId)
|
||||
} else if (qc.method == "deleteAccount") {
|
||||
deleteAccount();
|
||||
} else if (qc.method == "registerPushNotificationEndpoint") {
|
||||
registerPushNotificationEndpoint(qc.arg1, qc.arg2, qc.arg3);
|
||||
registerPushNotificationEndpoint(qc.arg1, qc.arg2, qc.arg3, qc.arg4, qc.arg5);
|
||||
} else if (qc.method == "unpairDevice") {
|
||||
unpairDevice(qc.arg1);
|
||||
}
|
||||
|
||||
@ -120,7 +120,8 @@ public:
|
||||
Q_INVOKABLE bool postToMQTT(const QString &boxId, const QString ×tamp, std::function<void(bool)> callback);
|
||||
Q_INVOKABLE void getId();
|
||||
|
||||
Q_INVOKABLE void registerPushNotificationEndpoint(const QString ®istrationId, const QString &deviceDisplayName, const QString mobileDeviceId);
|
||||
Q_INVOKABLE void registerPushNotificationEndpoint(const QString ®istrationId, const QString &deviceDisplayName, const QString mobileDeviceId, const QString &mobileDeviceManufacturer, const QString &mobileDeviceModel);
|
||||
|
||||
|
||||
bool tokensExpired() const;
|
||||
QByteArray idToken() const;
|
||||
@ -182,12 +183,14 @@ private:
|
||||
public:
|
||||
QueuedCall(const QString &method): method(method) { }
|
||||
QueuedCall(const QString &method, const QString &arg1): method(method), arg1(arg1) { }
|
||||
QueuedCall(const QString &method, const QString &arg1, const QString &arg2, const QString &arg3): method(method), arg1(arg1), arg2(arg2), arg3(arg3) { }
|
||||
QueuedCall(const QString &method, const QString &arg1, const QString &arg2, const QString &arg3, const QString &arg4, const QString &arg5): method(method), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4), arg5(arg5) { }
|
||||
QueuedCall(const QString &method, const QString &arg1, const QString &arg2, std::function<void(bool)> callback): method(method), arg1(arg1), arg2(arg2), callback(callback) {}
|
||||
QString method;
|
||||
QString arg1;
|
||||
QString arg2;
|
||||
QString arg3;
|
||||
QString arg4;
|
||||
QString arg5;
|
||||
std::function<void(bool)> callback;
|
||||
|
||||
static void enqueue(QList<QueuedCall> &queue, const QueuedCall &call) {
|
||||
|
||||
@ -8,6 +8,7 @@ class PlatformHelper : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool hasPermissions READ hasPermissions NOTIFY permissionsRequestFinished)
|
||||
Q_PROPERTY(QString deviceSerial READ deviceSerial CONSTANT)
|
||||
Q_PROPERTY(QString device READ device CONSTANT)
|
||||
Q_PROPERTY(QString deviceModel READ deviceModel CONSTANT)
|
||||
Q_PROPERTY(QString deviceManufacturer READ deviceManufacturer CONSTANT)
|
||||
Q_PROPERTY(QString machineHostname READ machineHostname CONSTANT)
|
||||
@ -29,6 +30,7 @@ public:
|
||||
|
||||
virtual bool hasPermissions() const = 0;
|
||||
virtual QString machineHostname() const = 0;
|
||||
virtual QString device() const = 0;
|
||||
virtual QString deviceSerial() const = 0;
|
||||
virtual QString deviceModel() const = 0;
|
||||
virtual QString deviceManufacturer() const = 0;
|
||||
|
||||
@ -44,6 +44,11 @@ QString PlatformHelperAndroid::deviceSerial() const
|
||||
return activity.callObjectMethod<jstring>("deviceSerial").toString();
|
||||
}
|
||||
|
||||
QString PlatformHelperAndroid::device() const
|
||||
{
|
||||
return QAndroidJniObject::callStaticObjectMethod<jstring>("io/guh/nymeaapp/NymeaAppActivity","device").toString();
|
||||
}
|
||||
|
||||
QString PlatformHelperAndroid::deviceModel() const
|
||||
{
|
||||
return QAndroidJniObject::callStaticObjectMethod<jstring>("io/guh/nymeaapp/NymeaAppActivity","deviceModel").toString();
|
||||
|
||||
@ -18,6 +18,7 @@ public:
|
||||
bool hasPermissions() const override;
|
||||
QString machineHostname() const override;
|
||||
QString deviceSerial() const override;
|
||||
QString device() const override;
|
||||
QString deviceModel() const override;
|
||||
QString deviceManufacturer() const override;
|
||||
|
||||
|
||||
@ -25,6 +25,11 @@ QString PlatformHelperGeneric::machineHostname() const
|
||||
return QSysInfo::machineHostName();
|
||||
}
|
||||
|
||||
QString PlatformHelperGeneric::device() const
|
||||
{
|
||||
return QSysInfo::prettyProductName();
|
||||
}
|
||||
|
||||
QString PlatformHelperGeneric::deviceSerial() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
|
||||
@ -16,6 +16,7 @@ public:
|
||||
|
||||
virtual bool hasPermissions() const override;
|
||||
virtual QString machineHostname() const override;
|
||||
virtual QString device() const override;
|
||||
virtual QString deviceSerial() const override;
|
||||
virtual QString deviceModel() const override;
|
||||
virtual QString deviceManufacturer() const override;
|
||||
|
||||
@ -27,6 +27,11 @@ QString PlatformHelperIOS::machineHostname() const
|
||||
return QSysInfo::machineHostName();
|
||||
}
|
||||
|
||||
QString PlatformHelperIOS::device() const
|
||||
{
|
||||
return deviceModel();
|
||||
}
|
||||
|
||||
QString PlatformHelperIOS::deviceSerial() const
|
||||
{
|
||||
// There is no way on iOS to get to a persistent serial number of the device.
|
||||
|
||||
@ -17,6 +17,7 @@ public:
|
||||
|
||||
virtual bool hasPermissions() const override;
|
||||
virtual QString machineHostname() const override;
|
||||
virtual QString device() const override;
|
||||
virtual QString deviceSerial() const override;
|
||||
virtual QString deviceModel() const override;
|
||||
virtual QString deviceManufacturer() const override;
|
||||
|
||||
@ -105,6 +105,8 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
setupPushNotifications();
|
||||
|
||||
if (tabSettings.lastConnectedHost.length > 0) {
|
||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||
var cachedHost = discovery.nymeaHosts.find(tabSettings.lastConnectedHost);
|
||||
@ -181,6 +183,7 @@ Item {
|
||||
if (askForPermissions === undefined) {
|
||||
askForPermissions = true;
|
||||
}
|
||||
print("********************************", PlatformHelper.device, PlatformHelper.deviceManufacturer, PlatformHelper.deviceModel)
|
||||
|
||||
if (!AWSClient.isLoggedIn) {
|
||||
print("AWS not logged in. Cannot register for push");
|
||||
@ -197,7 +200,7 @@ Item {
|
||||
PlatformHelper.requestPermissions();
|
||||
}
|
||||
} else {
|
||||
AWSClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.machineHostname, PlatformHelper.deviceSerial + "+io.guh.nymeaapp");
|
||||
AWSClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.machineHostname, PlatformHelper.deviceSerial + "+io.guh.nymeaapp", PlatformHelper.deviceManufacturer, PlatformHelper.deviceModel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,6 +268,7 @@ Item {
|
||||
Connections {
|
||||
target: PushNotifications
|
||||
onTokenChanged: {
|
||||
print("Push token changed", PlatformHelper.deviceManufacturer, PlatformHelper.deviceModel)
|
||||
setupPushNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,11 @@ public class NymeaAppActivity extends org.qtproject.qt5.android.bindings.QtActiv
|
||||
return Build.MODEL;
|
||||
}
|
||||
|
||||
public static String device()
|
||||
{
|
||||
return Build.DEVICE;
|
||||
}
|
||||
|
||||
public void vibrate(int duration)
|
||||
{
|
||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
Reference in New Issue
Block a user