-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathParseFacebook+combine.swift
134 lines (126 loc) · 5.62 KB
/
ParseFacebook+combine.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// ParseFacebook+combine.swift
// ParseFacebook+combine
//
// Created by Corey Baker on 8/7/21.
// Copyright © 2021 Parse Community. All rights reserved.
//
#if canImport(Combine)
import Foundation
import Combine
public extension ParseFacebook {
// MARK: Login - Combine
/**
Login a `ParseUser` *asynchronously* using Facebook authentication for limited login. Publishes when complete.
- parameter userId: The `userId` from `FacebookSDK`.
- parameter authenticationToken: The `authenticationToken` from `FacebookSDK`.
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(userId: String,
authenticationToken: String,
expiresIn: Int? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(userId: userId,
authenticationToken: authenticationToken,
expiresIn: expiresIn,
options: options,
completion: promise)
}
}
/**
Login a `ParseUser` *asynchronously* using Facebook authentication for graph API login. Publishes when complete.
- parameter userId: The `userId` from `FacebookSDK`.
- parameter accessToken: The `accessToken` from `FacebookSDK`.
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(userId: String,
accessToken: String,
expiresIn: Int? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(userId: userId,
accessToken: accessToken,
expiresIn: expiresIn,
options: options,
completion: promise)
}
}
/**
Login a `ParseUser` *asynchronously* using Facebook authentication for graph API login. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(authData: authData,
options: options,
completion: promise)
}
}
}
public extension ParseFacebook {
// MARK: Link - Combine
/**
Link the *current* `ParseUser` *asynchronously* using Facebook authentication for limited login.
Publishes when complete.
- parameter userId: The `userId` from `FacebookSDK`.
- parameter authenticationToken: The `authenticationToken` from `FacebookSDK`.
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(userId: String,
authenticationToken: String,
expiresIn: Int? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(userId: userId,
authenticationToken: authenticationToken,
expiresIn: expiresIn,
options: options,
completion: promise)
}
}
/**
Link the *current* `ParseUser` *asynchronously* using Facebook authentication for graph API login.
Publishes when complete.
- parameter userId: The `userId` from `FacebookSDK`.
- parameter accessToken: The `accessToken` from `FacebookSDK`.
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(userId: String,
accessToken: String,
expiresIn: Int? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(userId: userId,
accessToken: accessToken,
expiresIn: expiresIn,
options: options,
completion: promise)
}
}
/**
Link the *current* `ParseUser` *asynchronously* using Facebook authentication for graph API login.
Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(authData: authData,
options: options,
completion: promise)
}
}
}
#endif