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
#import "FirebaseMessaging/Sources/Token/FIRMessagingAPNSInfo.h"
20
 
21
NS_ASSUME_NONNULL_BEGIN
22
 
23
/**
24
 *  Represents an Instance ID token, and all of the relevant information
25
 *  associated with it. It can read from and write to an NSDictionary object, for
26
 *  simple serialization.
27
 */
28
@interface FIRMessagingTokenInfo : NSObject <NSCoding>
29
 
30
/// The authorized entity (also known as Sender ID), associated with the token.
31
@property(nonatomic, readonly, copy) NSString *authorizedEntity;
32
/// The scope associated with the token. This is an arbitrary string, typically "*".
33
@property(nonatomic, readonly, copy) NSString *scope;
34
/// The token value itself, with which all other properties are associated.
35
@property(nonatomic, readonly, copy) NSString *token;
36
 
37
// These properties are nullable because they might not exist for tokens fetched from
38
// legacy storage formats.
39
 
40
/// The app version that this token represents.
41
@property(nonatomic, readonly, copy, nullable) NSString *appVersion;
42
/// The Firebase app ID (also known as GMP App ID), that this token is associated with.
43
@property(nonatomic, readonly, copy, nullable) NSString *firebaseAppID;
44
 
45
/// Tokens may not always be associated with an APNs token, and may be associated after
46
/// being created.
47
@property(nonatomic, strong, nullable) FIRMessagingAPNSInfo *APNSInfo;
48
/// The time that this token info was updated. The cache time is writeable, since in
49
/// some cases the token info may be refreshed from the server. In those situations,
50
/// the cacheTime would be updated.
51
@property(nonatomic, copy, nullable) NSDate *cacheTime;
52
 
53
/**
54
 *  Initializes a FIRMessagingTokenInfo object with the required parameters. These
55
 *  parameters represent all the relevant associated data with a token.
56
 *
57
 *  @param authorizedEntity The authorized entity (also known as Sender ID).
58
 *  @param scope            The scope of the token, typically "*" meaning
59
 *                          it's a "default scope".
60
 *  @param token            The token value itself.
61
 *  @param appVersion       The application version that this token is associated with.
62
 *  @param firebaseAppID    The Firebase app ID which this token is associated with.
63
 *  @return An instance of FIRMessagingTokenInfo.
64
 */
65
- (instancetype)initWithAuthorizedEntity:(NSString *)authorizedEntity
66
                                   scope:(NSString *)scope
67
                                   token:(NSString *)token
68
                              appVersion:(nullable NSString *)appVersion
69
                           firebaseAppID:(nullable NSString *)firebaseAppID;
70
 
71
/**
72
 * Check whether the token is still fresh based on:
73
 * 1. Last fetch token is within the 7 days.
74
 * 2. Language setting is not changed.
75
 * 3. App version is current.
76
 * 4. GMP App ID is current.
77
 * 5. token is consistent with the current IID.
78
 * 6. APNS info has changed.
79
 * @param IID  The app identifiier that is used to check if token is prefixed with.
80
 * @return If token is fresh.
81
 *
82
 */
83
- (BOOL)isFreshWithIID:(NSString *)IID;
84
 
85
/*
86
 * Check whether the token is default token.
87
 */
88
- (BOOL)isDefaultToken;
89
 
90
@end
91
 
92
NS_ASSUME_NONNULL_END