Make it work on iOS

This commit is contained in:
Michael Zanetti 2020-12-12 17:51:08 +01:00 committed by Michael Zanetti
parent ae26b505b1
commit 0a2b656dba
2 changed files with 12 additions and 6 deletions

View File

@ -390,7 +390,7 @@ Page {
Layout.fillWidth: true Layout.fillWidth: true
enabled: !model.readOnly enabled: !model.readOnly
paramType: root.deviceClass.paramTypes.get(index) paramType: root.deviceClass.paramTypes.get(index)
visible: root.thingClass.id.toString().match(/\{?f0dd4c03-0aca-42cc-8f34-9902457b05de\}?/) === null //visible: root.thingClass.id.toString().match(/\{?f0dd4c03-0aca-42cc-8f34-9902457b05de\}?/) === null
value: { value: {
// Discovery, use params from discovered descriptor // Discovery, use params from discovered descriptor
if (d.thingDescriptor && d.thingDescriptor.params.getParam(paramType.id)) { if (d.thingDescriptor && d.thingDescriptor.params.getParam(paramType.id)) {
@ -400,12 +400,13 @@ Page {
// Special hook for push notifications as we need to provide the token implicitly // Special hook for push notifications as we need to provide the token implicitly
print("Setting up params for thing class:", root.thingClass.id, root.thingClass.name) print("Setting up params for thing class:", root.thingClass.id, root.thingClass.name)
if (root.thingClass.id.toString().match(/\{?f0dd4c03-0aca-42cc-8f34-9902457b05de\}?/)) { if (root.thingClass.id.toString().match(/\{?f0dd4c03-0aca-42cc-8f34-9902457b05de\}?/)) {
print("It's push notifications. Token is:", PushNotifications.token, "Platform is:", Qt.platform.os);
if (paramType.id.toString().match(/\{?3cb8e30e-2ec5-4b4b-8c8c-03eaf7876839\}?/)) { if (paramType.id.toString().match(/\{?3cb8e30e-2ec5-4b4b-8c8c-03eaf7876839\}?/)) {
if (Qt.platform.os == "android") { if (Qt.platform.os == "android") {
return "GCM"; return "GCM";
} else if (Qt.platform.os == "ios") {
return "APNs"
} else { } else {
print("Unsupported platform for push notifications!") print("Unsupported platform for push notifications:", Qt.platform.os)
} }
} }
if (paramType.id.toString().match(/\{?12ec06b2-44e7-486a-9169-31c684b91c8f\}?/)) { if (paramType.id.toString().match(/\{?12ec06b2-44e7-486a-9169-31c684b91c8f\}?/)) {

View File

@ -53,10 +53,11 @@
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]), ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])]; ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
qDebug() << "Registering for remote notifications";
qDebug() << "Token description:" << QString::fromNSString(deviceToken.description);
qDebug() << "Parsed token:" << QString::fromNSString(tokenStr);
// We've switched to firebase... Not emitting the native APNS token // We've switched to firebase... Not emitting the native APNS token
// qDebug() << "Registering for remote notifications";
// qDebug() << "Token description:" << QString::fromNSString(deviceToken.description);
// qDebug() << "Parsed token:" << QString::fromNSString(tokenStr);
// PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(tokenStr)); // PushNotifications::instance()->setAPNSRegistrationToken(QString::fromNSString(tokenStr));
} }
@ -98,4 +99,8 @@
} }
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo {
qDebug() << "didReceiveRemoteNotification called";
}
@end @end