You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**
10
+
**This SDK is compatible with Appwrite server version 1.0.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**
11
11
12
12
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
13
13
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
To initialize your SDK and start interacting with Appwrite services, you need to add a new Apple platform to your project. To add a new platform, go to your Appwrite console, select your project (create one if you haven't already), and click the 'Add Platform' button on the project Dashboard.
55
+
56
+
From the options, choose to add a new **iOS**, **macOS**, **watchOS** or **tvOS** platform and add your app credentials.
57
+
58
+
Add your app <u>name</u> and <u>bundle identifier</u>. Your bundle identifier can be found in your Xcode project file or your `Info.plist` file. By registering a new platform, you are allowing your app to communicate with the Appwrite API.
59
+
60
+
### Registering URL schemes
61
+
62
+
In order to capture the Appwrite OAuth callback url, the following URL scheme needs to be added to project. You can add this from Xcode by selecting your project file, then the target you wish to use OAuth with. From the `Info` tab, expand the `URL types` section and add your Appwrite instance domain for the `Identifier`, and `appwrite-callback-[PROJECT-ID]` for the `URL scheme`. Be sure to replace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in the console. Alternatively, you can add the following block directly to your targets `Info.plist` file:
63
+
64
+
```xml
65
+
<key>CFBundleURLTypes</key>
66
+
<array>
67
+
<dict>
68
+
<key>CFBundleTypeRole</key>
69
+
<string>Editor</string>
70
+
<key>CFBundleURLName</key>
71
+
<string>io.appwrite</string>
72
+
<key>CFBundleURLSchemes</key>
73
+
<array>
74
+
<string>appwrite-callback-[PROJECT-ID]</string>
75
+
</array>
76
+
</dict>
77
+
</array>
78
+
```
79
+
80
+
Next we need to add a hook to save cookies when our app is opened by its callback URL.
81
+
82
+
### Registering an OAuth handler view
83
+
84
+
> If you're using UIKit, you can skip this section.
85
+
86
+
In SwiftUI this is as simple as ensuring `.registerOAuthHanlder()` is called on the `View` you want to invoke an OAuth request from.
87
+
88
+
### Updating the SceneDelegate for UIKit
89
+
90
+
> If you're using SwiftUI, you can skip this section.
91
+
92
+
For UIKit, you need to add the following function to your `SceneDelegate.swift`. If you have already defined this function, you can just add the contents from below.
Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.
107
+
108
+
```swift
109
+
importAppwrite
110
+
111
+
funcmain() {
112
+
let client =Client()
113
+
.setEndpoint("http://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
114
+
.setProject("5df5acd0d48c2") // Your project ID
115
+
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
116
+
}
117
+
```
118
+
119
+
### Make Your First Request
120
+
121
+
Once your SDK object is initialized, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
When an error occurs, the Appwrite Apple SDK throws an `AppwriteError` object with `message` and `code` properties. You can handle any errors in a catch block and present the `message` or `localizedDescription` to the user or handle it yourself based on the provided error information. Below is an example.
167
+
168
+
```swift
169
+
importAppwrite
170
+
171
+
funcmain() {
172
+
let account =Account(client)
173
+
174
+
do {
175
+
let user =tryawait account.get()
176
+
print(String(describing: user.toMap()))
177
+
} catch {
178
+
print(error.localizedDescription)
179
+
}
180
+
}
181
+
```
182
+
183
+
### Learn more
184
+
185
+
You can use the following resources to learn more and get help
186
+
187
+
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 🚂 [Appwrite Swift Playground](https://github.com/appwrite/playground-for-swift-server)
191
+
192
+
51
193
## Contribution
52
194
53
195
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
0 commit comments