-
Notifications
You must be signed in to change notification settings - Fork 11
/
ParseFacebookUtils+PromiseKit.m
73 lines (64 loc) · 2.39 KB
/
ParseFacebookUtils+PromiseKit.m
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
//
// ParseFacebookUtils+PromiseKit.m
//
// Created by DJ Tarazona on 9/16/14.
// Copyright (c) 2014 Hathway Inc.
//
#import "ParseFacebookUtils+PromiseKit.h"
#import "PMKPFMacros.h"
#import <Promise.h>
@implementation PFFacebookUtils (PromiseKit)
+ (PMKPromise *)promiseLogInWithPermissions:(NSArray *)permissions
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self logInWithPermissions:permissions block:PMKPFUserResultBlock];
}];
}
+ (PMKPromise *)promiseLogInWithFacebookId:(NSString *)facebookId
accessToken:(NSString *)accessToken
expirationDate:(NSDate *)expirationDate
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self logInWithFacebookId:facebookId
accessToken:accessToken
expirationDate:expirationDate
block:PMKPFUserResultBlock];
}];
}
+ (PMKPromise *)promiseLinkUser:(PFUser *)user permissions:(NSArray *)permissions
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self linkUser:user permissions:permissions block:PMKPFBooleanResultBlock];
}];
}
+ (PMKPromise *)promiseLinkUser:(PFUser *)user
facebookId:(NSString *)facebookId
accessToken:(NSString *)accessToken
expirationDate:(NSDate *)expirationDate
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self linkUser:user
facebookId:facebookId
accessToken:accessToken
expirationDate:expirationDate
block:PMKPFBooleanResultBlock];
}];
}
+ (PMKPromise *)promiseUnlinkUser:(PFUser *)user
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self unlinkUserInBackground:user block:PMKPFBooleanResultBlock];
}];
}
+ (PMKPromise *)promiseReauthorizeUser:(PFUser *)user
withPublishPermissions:(NSArray *)permissions
audience:(FBSessionDefaultAudience)audience
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfiller, PMKPromiseRejecter rejecter) {
[self reauthorizeUser:user
withPublishPermissions:permissions
audience:audience
block:PMKPFBooleanResultBlock];
}];
}
@end