Skip to content

Commit

Permalink
Merge pull request #469 from mindbox-cloud/feature/WMRUSTORE-6
Browse files Browse the repository at this point in the history
WMRUSTORE-6: Change token format for MobileApplicationInfoUpdated and MobileApplicationInstalled events
  • Loading branch information
enotniy authored Dec 2, 2024
2 parents 19c9b09 + c1f7589 commit 69e16ab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Mindbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
B3F4F982268EEAC90092EC3C /* AmountBenefitsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3F4F980268EEAC90092EC3C /* AmountBenefitsResponse.swift */; };
B3F4F98A268EEB360092EC3C /* PeriodTypeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3F4F989268EEB360092EC3C /* PeriodTypeResponse.swift */; };
B3F4F98E268EEB4B0092EC3C /* LimitBenefitsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3F4F98D268EEB4B0092EC3C /* LimitBenefitsResponse.swift */; };
B4547ECA2CFA0EC6001478AD /* TokenData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4547EC92CFA0EC6001478AD /* TokenData.swift */; };
BB4D7CC72BDEC51D008E3AB8 /* Notification+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4D7CC62BDEC51D008E3AB8 /* Notification+Extensions.swift */; };
BB6563102BE3BA430090C473 /* UIApplication+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB65630F2BE3BA430090C473 /* UIApplication+Extensions.swift */; };
BBAAC17C2BB2FC9100E1E25E /* MockEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAAC17B2BB2FC9100E1E25E /* MockEvent.swift */; };
Expand Down Expand Up @@ -943,6 +944,7 @@
B3F4F985268EEADE0092EC3C /* LimitBenefitsResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitBenefitsResponse.swift; sourceTree = "<group>"; };
B3F4F989268EEB360092EC3C /* PeriodTypeResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeriodTypeResponse.swift; sourceTree = "<group>"; };
B3F4F98D268EEB4B0092EC3C /* LimitBenefitsResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitBenefitsResponse.swift; sourceTree = "<group>"; };
B4547EC92CFA0EC6001478AD /* TokenData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenData.swift; sourceTree = "<group>"; };
BB4D7CC62BDEC51D008E3AB8 /* Notification+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Notification+Extensions.swift"; sourceTree = "<group>"; };
BB65630F2BE3BA430090C473 /* UIApplication+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+Extensions.swift"; sourceTree = "<group>"; };
BBAAC17B2BB2FC9100E1E25E /* MockEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockEvent.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1923,6 +1925,7 @@
84C65E5B25D4FB71008996FA /* Bodies */ = {
isa = PBXGroup;
children = (
B4547EC92CFA0EC6001478AD /* TokenData.swift */,
84F565202628304A00269FD6 /* TrackVisit.swift */,
84C65E5D25D4FBA3008996FA /* MobileApplicationInstalled.swift */,
84C65E6325D4FBBB008996FA /* MobileApplicationInfoUpdated.swift */,
Expand Down Expand Up @@ -3547,6 +3550,7 @@
B3F4F982268EEAC90092EC3C /* AmountBenefitsResponse.swift in Sources */,
31A20D4C25B6E0D700AAA0A3 /* MindboxErrors.swift in Sources */,
334F3ADF264C199900A6AC00 /* SubViewProductRequest.swift in Sources */,
B4547ECA2CFA0EC6001478AD /* TokenData.swift in Sources */,
F331DD232A84BFDE00222120 /* CustomDecodingError.swift in Sources */,
6FDD1463266F7CED00A50C35 /* ProductElementReponse.swift in Sources */,
A192786C29D3A24000CDB53D /* ProductIDChecker.swift in Sources */,
Expand Down
20 changes: 11 additions & 9 deletions Mindbox/Model/Bodies/MobileApplicationInfoUpdated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@ import Foundation

struct MobileApplicationInfoUpdated: Codable {

let notificationProvider: String

let token: String

var isTokenAvailable: Bool

let isNotificationsEnabled: Bool

let version: Int

let instanceId: String

/// Храним единственный токен в массиве, потому что в таком формате его ожидает бекенд
let tokens: [TokenData]

init(token: String?,
isNotificationsEnabled: Bool,
version: Int,
instanceId: String,
notificationProvider: String = "APNS") {
self.token = token ?? ""
self.isTokenAvailable = !self.token.isEmpty

if let tokenValue = token, !tokenValue.isEmpty {
let tokenData = TokenData(token: tokenValue, notificationProvider: notificationProvider)
self.tokens = [tokenData]
} else {
self.tokens = []
}

self.isNotificationsEnabled = isNotificationsEnabled
self.version = version
self.instanceId = instanceId
self.notificationProvider = notificationProvider
}
}
19 changes: 10 additions & 9 deletions Mindbox/Model/Bodies/MobileApplicationInstalled.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import Foundation

struct MobileApplicationInstalled: Codable {

let notificationProvider: String

let token: String

var isTokenAvailable: Bool

let isNotificationsEnabled: Bool

let installationId: String
Expand All @@ -31,6 +25,9 @@ struct MobileApplicationInstalled: Codable {
/// ID текущая таймзона устройства в формате IANA, например "Asia/Krasnoyarsk", null если недоступно
let ianaTimeZone: String?

/// Храним единственный токен в массиве, потому что в таком формате его ожидает бекенд
let tokens: [TokenData]

init(
token: String? = nil,
isNotificationsEnabled: Bool,
Expand All @@ -42,15 +39,19 @@ struct MobileApplicationInstalled: Codable {
notificationProvider: String = "APNS",
ianaTimeZone: String?
) {
self.token = token ?? ""
self.isTokenAvailable = !self.token.isEmpty
if let tokenValue = token, !tokenValue.isEmpty {
let tokenData = TokenData(token: tokenValue, notificationProvider: notificationProvider)
self.tokens = [tokenData]
} else {
self.tokens = []
}

self.isNotificationsEnabled = isNotificationsEnabled
self.installationId = installationId ?? ""
self.subscribe = subscribe ?? false
self.externalDeviceUUID = externalDeviceUUID
self.version = version
self.instanceId = instanceId
self.notificationProvider = notificationProvider
self.ianaTimeZone = ianaTimeZone
}
}
15 changes: 15 additions & 0 deletions Mindbox/Model/Bodies/TokenData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// TokenData.swift
// Pods
//
// Created by Egor Kitselyuk on 29.11.2024.
//

import Foundation

struct TokenData: Codable {

let token: String

let notificationProvider: String
}

0 comments on commit 69e16ab

Please sign in to comment.