Skip to content

Commit

Permalink
Merge pull request #184 from pusher/get-user
Browse files Browse the repository at this point in the history
added getter for UserId
  • Loading branch information
marcelcorso authored Jul 4, 2022
2 parents 28fe697 + 0cbd1ae commit 441a6de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Sources/PushNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ import Foundation
}
self.serverSyncHandler.sendMessage(serverSyncJob: .setUserIdJob(userId: userId))
}

/**
Get the UserId that the device is currently authenticated to.

- returns: string of UserId
*/
/// - Tag: getUserId
@objc public func getUserId() -> String? {
return InstanceDeviceStateStore.synchronize {
return self.deviceStateStore.getUserId()
}
}

@objc private func printHelpfulMessage() {
print("[PushNotifications] - It looks like setUserId hasn't completed yet -- have you called `registerDeviceToken`?")
Expand Down
15 changes: 14 additions & 1 deletion Sources/PushNotificationsStatic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,20 @@ import Foundation
fatalError("PushNotifications.shared.start must have been called first")
}
}


/**
Get the UserId that the device is currently authenticated to.

- returns: string of UserId
*/
/// - Tag: getUserId
@objc public static func getUserId() -> String? {
if let staticInstance = instance {
return staticInstance.getUserId()
} else {
fatalError("PushNotifications.shared.start must have been called first")
}
}
/**
Disable Beams service.

Expand Down

0 comments on commit 441a6de

Please sign in to comment.