Skip to content

Commit bb09138

Browse files
committed
Add properties to Subscription Model
* Fill out the rest of the properties on a push subscription model like the `app_version` and `net_type` * I chose to omit `rooted` and `carrier` in this PR as rooted doesn't appear to be sent to the server for iOS devices and Apple methods to retrieve carrier are being deprecated.
1 parent cc52467 commit bb09138

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ class OSSubscriptionModel: OSModel {
191191
let deviceOs = UIDevice.current.systemVersion
192192
let sdk = ONESIGNAL_VERSION
193193
let deviceModel: String? = OSDeviceUtils.getDeviceVariant()
194+
let appVersion: String? = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
195+
let netType: Int? = OSNetworkingUtils.getNetType() as? Int
194196

195197
// When a Subscription is initialized, it may not have a subscriptionId until a request to the backend is made.
196198
init(type: OSSubscriptionType,
@@ -231,6 +233,7 @@ class OSSubscriptionModel: OSModel {
231233
coder.encode(_accepted, forKey: "_accepted")
232234
coder.encode(_isDisabled, forKey: "_isDisabled")
233235
coder.encode(notificationTypes, forKey: "notificationTypes")
236+
coder.encode(testType, forKey: "testType")
234237
}
235238

236239
required init?(coder: NSCoder) {
@@ -247,6 +250,7 @@ class OSSubscriptionModel: OSModel {
247250
self._accepted = coder.decodeBool(forKey: "_accepted")
248251
self._isDisabled = coder.decodeBool(forKey: "_isDisabled")
249252
self.notificationTypes = coder.decodeInteger(forKey: "notificationTypes")
253+
self.testType = coder.decodeObject(forKey: "testType") as? Int
250254
super.init(coder: coder)
251255
}
252256

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ class OSRequestCreateUser: OneSignalRequest, OSUserRequest {
331331
pushSubscriptionObject["type"] = pushSubscriptionModel.type.rawValue
332332
pushSubscriptionObject["token"] = pushSubscriptionModel.address
333333
pushSubscriptionObject["enabled"] = pushSubscriptionModel.enabled
334-
335334
pushSubscriptionObject["test_type"] = pushSubscriptionModel.testType
336335
pushSubscriptionObject["device_os"] = pushSubscriptionModel.deviceOs
337336
pushSubscriptionObject["sdk"] = pushSubscriptionModel.sdk
338337
pushSubscriptionObject["device_model"] = pushSubscriptionModel.deviceModel
339-
338+
pushSubscriptionObject["app_version"] = pushSubscriptionModel.appVersion
339+
pushSubscriptionObject["net_type"] = pushSubscriptionModel.netType
340340
// notificationTypes defaults to -1 instead of nil, don't send if it's -1
341341
if pushSubscriptionModel.notificationTypes != -1 {
342342
pushSubscriptionObject["notification_types"] = pushSubscriptionModel.notificationTypes

0 commit comments

Comments
 (0)