hank
2018-06-21 c12e51375398dcb27b77d0ffda02f50adfedf454
commit | author | age
655e66 1 /*
H 2  * Copyright (C) 2017 Twitter, Inc.
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
18 /**
19  This header is private to the Twitter Core SDK and not exposed for public SDK consumption
20  */
a0a843 21
H 22 @class TWTRUserSessionVerifier;
23
24 @protocol TWTRUserSessionVerifierDelegate <NSObject>
25
26 - (void)userSessionVerifierNeedsSessionVerification:(TWTRUserSessionVerifier *)userSessionVerifier;
27
28 @end
29
655e66 30 FOUNDATION_EXTERN NSTimeInterval const TWTRUserSessionVerifierIntervalDaily;
H 31 FOUNDATION_EXTERN NSTimeInterval const TWTRUserSessionVerifierDefaultDelay;
a0a843 32
H 33 /**
34  *  Manages verifying stored user sessions on a daily basis. This class depends on the Kit lifecycle
35  *  and `UIApplicationWillEnterForegroundNotification` event and checks whether the last verified
36  *  time has exceeded a day based on UTC date boundaries. Note that this does not mean we will aggressively
37  *  verify the second day of someone that started using the app at 11:59P and continues past 12:00A
38  *  due to 1) avoiding load spike to backend and 2) there is no good reliable way to randomize the
39  *  scheduling of the second verification due to constraints of iOS. Last verified time is only stored in memory
40  *  to minimize overhead on the host application. Verification is done on a best effort basis and we
41  *  will not retry if the network call fails for whatever reason.
42  */
43 @interface TWTRUserSessionVerifier : NSObject
44
655e66 45 - (instancetype)init NS_UNAVAILABLE;
a0a843 46
H 47 /**
48  *  Initializes a verifier for the current consumer application.
49  *
50  *  @param delegate           An object that will handle the verification of the session when necessary
51  *  @param maxDesiredInterval maximum desireable interval for how frequently a verify call should be made while
52  *                            the host app is active. Calls might be made more frequently if the app is used
53  *                            during the previous and current interval boundaries or we cannot not tell when
54  *                            the last call was made. The latter will be de-dup on the backend.
55  */
56 - (instancetype)initWithDelegate:(id<TWTRUserSessionVerifierDelegate>)delegate maxDesiredInterval:(NSTimeInterval)maxDesiredInterval __attribute__((nonnull(1)))NS_DESIGNATED_INITIALIZER;
57
58 /**
59  *  Makes a verify call immediately (delayed slightly to minimize app startup impact) and then
60  *  subscribes to `UIApplicationWillEnterForegroundNotification` to check for the next time we should
61  *  be making a verify call.
62  *
63  *  @param delay The minimum time before which the message is sent. Specifying a delay of 0 does not
64  *               necessarily cause the selector to be performed immediately. The first verification is
65  *               still queued on the thread’s run loop and performed as soon as possible.
66  */
67 - (void)startVerificationAfterDelay:(NSTimeInterval)delay;
68
69 @end