Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #24

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ messenger?.setPushRegistrationToken(token: token)
Prerequisite: The application should be connected to the notifications platform, enabled for receiving notifications and obtaining tokens.



## Privacy

In order to make the file upload and download fully work, make sure to add these permissions with appropriate messages in your `Info.plist` file:
- Privacy - Camera Usage Description
- Privacy - Microphone Usage Description
- Privacy - Photo Library Additions Usage Description

## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/deskpro/messenger-sdk-ios/tags).

20 changes: 17 additions & 3 deletions Sources/Deskpro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,23 @@ import UIKit
/// - Returns: A [PresentBuilder](x-source-tag://PresentBuilder) instance to start building presentation paths.
///
@objc public final func present() -> PresentBuilder {
let url = messengerConfig.appUrl//.appending(messengerConfig.appId)
//return PresentBuilder(url: url, containingViewController: containingViewController)
return PresentBuilder(url: url, appId: messengerConfig.appId, coordinator: coordinator)
let url = buildUrl(baseUrl: messengerConfig.appUrl, appId: messengerConfig.appId)
return PresentBuilder(url: url ?? "", appId: messengerConfig.appId, coordinator: coordinator)
}

func buildUrl(baseUrl: String, appId: String) -> String? {
let platformData = ["platform": "IOS"]

guard let platformJsonData = try? JSONSerialization.data(withJSONObject: platformData, options: []),
let platformJsonString = String(data: platformJsonData, encoding: .utf8),
let encodedPlatform = platformJsonString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
return nil
}

let formattedBaseUrl = baseUrl.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
let formattedAppId = "/" + appId.trimmingCharacters(in: CharacterSet(charactersIn: "/"))

return "\(formattedBaseUrl)\(formattedAppId)/\(encodedPlatform)"
}

/// Closes the chat view presented by the DeskPro SDK.
Expand Down
Loading