Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2019 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <Foundation/Foundation.h>
18
 
19
@class FIRMessagingCheckinPreferences;
20
 
21
NS_ASSUME_NONNULL_BEGIN
22
 
23
/**
24
 *  Represents the action taken on an FCM token.
25
 */
26
typedef NS_ENUM(NSInteger, FIRMessagingTokenAction) {
27
  FIRMessagingTokenActionFetch,
28
  FIRMessagingTokenActionDeleteToken,
29
  FIRMessagingTokenActionDeleteTokenAndIID,
30
};
31
 
32
/**
33
 * Represents the possible results of a token operation.
34
 */
35
typedef NS_ENUM(NSInteger, FIRMessagingTokenOperationResult) {
36
  FIRMessagingTokenOperationSucceeded,
37
  FIRMessagingTokenOperationError,
38
  FIRMessagingTokenOperationCancelled,
39
};
40
 
41
/**
42
 *  Callback to invoke once the HTTP call to FIRMessaging backend for updating
43
 *  subscription finishes.
44
 *
45
 *  @param result  The result of the operation.
46
 *  @param token   If the action for fetching a token and the request was successful, this will hold
47
 *                 the value of the token. Otherwise nil.
48
 *  @param error   The error which occurred while performing the token operation. This will be nil
49
 *                 in case the operation was successful, or if the operation was cancelled.
50
 */
51
typedef void (^FIRMessagingTokenOperationCompletion)(FIRMessagingTokenOperationResult result,
52
                                                     NSString *_Nullable token,
53
                                                     NSError *_Nullable error);
54
 
55
@interface FIRMessagingTokenOperation : NSOperation
56
 
57
@property(nonatomic, readonly) FIRMessagingTokenAction action;
58
@property(nonatomic, readonly, nullable) NSString *authorizedEntity;
59
@property(nonatomic, readonly, nullable) NSString *scope;
60
@property(nonatomic, readonly, nullable) NSDictionary<NSString *, NSString *> *options;
61
@property(nonatomic, readonly, strong) FIRMessagingCheckinPreferences *checkinPreferences;
62
@property(nonatomic, readonly, strong) NSString *instanceID;
63
 
64
@property(nonatomic, readonly) FIRMessagingTokenOperationResult result;
65
 
66
@property(atomic, strong, nullable) NSURLSessionDataTask *dataTask;
67
 
68
#pragma mark - Request Construction
69
+ (NSMutableArray<NSURLQueryItem *> *)standardQueryItemsWithDeviceID:(NSString *)deviceID
70
                                                               scope:(NSString *)scope;
71
- (NSMutableURLRequest *)tokenRequest;
72
- (instancetype)init NS_UNAVAILABLE;
73
 
74
#pragma mark - Initialization
75
- (instancetype)initWithAction:(FIRMessagingTokenAction)action
76
           forAuthorizedEntity:(nullable NSString *)authorizedEntity
77
                         scope:(NSString *)scope
78
                       options:(nullable NSDictionary<NSString *, NSString *> *)options
79
            checkinPreferences:(FIRMessagingCheckinPreferences *)checkinPreferences
80
                    instanceID:(NSString *)instanceID;
81
 
82
- (void)addCompletionHandler:(FIRMessagingTokenOperationCompletion)handler;
83
 
84
#pragma mark - Result
85
- (void)finishWithResult:(FIRMessagingTokenOperationResult)result
86
                   token:(nullable NSString *)token
87
                   error:(nullable NSError *)error;
88
@end
89
 
90
NS_ASSUME_NONNULL_END