Manos Chorianopoulos

barcode lib check

Showing 206 changed files with 627 additions and 2721 deletions
No preview for this file type
No preview for this file type
1 +// Generated by Apple Swift version 5.5.1 (swiftlang-1300.0.31.4 clang-1300.0.29.6)
2 +#ifndef WARPLYSDKFRAMEWORKIOS_SWIFT_H
3 +#define WARPLYSDKFRAMEWORKIOS_SWIFT_H
4 +#pragma clang diagnostic push
5 +#pragma clang diagnostic ignored "-Wgcc-compat"
6 +
7 +#if !defined(__has_include)
8 +# define __has_include(x) 0
9 +#endif
10 +#if !defined(__has_attribute)
11 +# define __has_attribute(x) 0
12 +#endif
13 +#if !defined(__has_feature)
14 +# define __has_feature(x) 0
15 +#endif
16 +#if !defined(__has_warning)
17 +# define __has_warning(x) 0
18 +#endif
19 +
20 +#if __has_include(<swift/objc-prologue.h>)
21 +# include <swift/objc-prologue.h>
22 +#endif
23 +
24 +#pragma clang diagnostic ignored "-Wauto-import"
25 +#include <Foundation/Foundation.h>
26 +#include <stdint.h>
27 +#include <stddef.h>
28 +#include <stdbool.h>
29 +
30 +#if !defined(SWIFT_TYPEDEFS)
31 +# define SWIFT_TYPEDEFS 1
32 +# if __has_include(<uchar.h>)
33 +# include <uchar.h>
34 +# elif !defined(__cplusplus)
35 +typedef uint_least16_t char16_t;
36 +typedef uint_least32_t char32_t;
37 +# endif
38 +typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
39 +typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
40 +typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
41 +typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
42 +typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
43 +typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
44 +typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
45 +typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
46 +typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
47 +typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
48 +typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
49 +typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
50 +#endif
51 +
52 +#if !defined(SWIFT_PASTE)
53 +# define SWIFT_PASTE_HELPER(x, y) x##y
54 +# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
55 +#endif
56 +#if !defined(SWIFT_METATYPE)
57 +# define SWIFT_METATYPE(X) Class
58 +#endif
59 +#if !defined(SWIFT_CLASS_PROPERTY)
60 +# if __has_feature(objc_class_property)
61 +# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
62 +# else
63 +# define SWIFT_CLASS_PROPERTY(...)
64 +# endif
65 +#endif
66 +
67 +#if __has_attribute(objc_runtime_name)
68 +# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
69 +#else
70 +# define SWIFT_RUNTIME_NAME(X)
71 +#endif
72 +#if __has_attribute(swift_name)
73 +# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
74 +#else
75 +# define SWIFT_COMPILE_NAME(X)
76 +#endif
77 +#if __has_attribute(objc_method_family)
78 +# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
79 +#else
80 +# define SWIFT_METHOD_FAMILY(X)
81 +#endif
82 +#if __has_attribute(noescape)
83 +# define SWIFT_NOESCAPE __attribute__((noescape))
84 +#else
85 +# define SWIFT_NOESCAPE
86 +#endif
87 +#if __has_attribute(ns_consumed)
88 +# define SWIFT_RELEASES_ARGUMENT __attribute__((ns_consumed))
89 +#else
90 +# define SWIFT_RELEASES_ARGUMENT
91 +#endif
92 +#if __has_attribute(warn_unused_result)
93 +# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
94 +#else
95 +# define SWIFT_WARN_UNUSED_RESULT
96 +#endif
97 +#if __has_attribute(noreturn)
98 +# define SWIFT_NORETURN __attribute__((noreturn))
99 +#else
100 +# define SWIFT_NORETURN
101 +#endif
102 +#if !defined(SWIFT_CLASS_EXTRA)
103 +# define SWIFT_CLASS_EXTRA
104 +#endif
105 +#if !defined(SWIFT_PROTOCOL_EXTRA)
106 +# define SWIFT_PROTOCOL_EXTRA
107 +#endif
108 +#if !defined(SWIFT_ENUM_EXTRA)
109 +# define SWIFT_ENUM_EXTRA
110 +#endif
111 +#if !defined(SWIFT_CLASS)
112 +# if __has_attribute(objc_subclassing_restricted)
113 +# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
114 +# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
115 +# else
116 +# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
117 +# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
118 +# endif
119 +#endif
120 +#if !defined(SWIFT_RESILIENT_CLASS)
121 +# if __has_attribute(objc_class_stub)
122 +# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME) __attribute__((objc_class_stub))
123 +# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_class_stub)) SWIFT_CLASS_NAMED(SWIFT_NAME)
124 +# else
125 +# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME)
126 +# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) SWIFT_CLASS_NAMED(SWIFT_NAME)
127 +# endif
128 +#endif
129 +
130 +#if !defined(SWIFT_PROTOCOL)
131 +# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
132 +# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
133 +#endif
134 +
135 +#if !defined(SWIFT_EXTENSION)
136 +# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
137 +#endif
138 +
139 +#if !defined(OBJC_DESIGNATED_INITIALIZER)
140 +# if __has_attribute(objc_designated_initializer)
141 +# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
142 +# else
143 +# define OBJC_DESIGNATED_INITIALIZER
144 +# endif
145 +#endif
146 +#if !defined(SWIFT_ENUM_ATTR)
147 +# if defined(__has_attribute) && __has_attribute(enum_extensibility)
148 +# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
149 +# else
150 +# define SWIFT_ENUM_ATTR(_extensibility)
151 +# endif
152 +#endif
153 +#if !defined(SWIFT_ENUM)
154 +# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
155 +# if __has_feature(generalized_swift_name)
156 +# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
157 +# else
158 +# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
159 +# endif
160 +#endif
161 +#if !defined(SWIFT_UNAVAILABLE)
162 +# define SWIFT_UNAVAILABLE __attribute__((unavailable))
163 +#endif
164 +#if !defined(SWIFT_UNAVAILABLE_MSG)
165 +# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
166 +#endif
167 +#if !defined(SWIFT_AVAILABILITY)
168 +# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
169 +#endif
170 +#if !defined(SWIFT_WEAK_IMPORT)
171 +# define SWIFT_WEAK_IMPORT __attribute__((weak_import))
172 +#endif
173 +#if !defined(SWIFT_DEPRECATED)
174 +# define SWIFT_DEPRECATED __attribute__((deprecated))
175 +#endif
176 +#if !defined(SWIFT_DEPRECATED_MSG)
177 +# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
178 +#endif
179 +#if __has_feature(attribute_diagnose_if_objc)
180 +# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
181 +#else
182 +# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
183 +#endif
184 +#if !defined(IBSegueAction)
185 +# define IBSegueAction
186 +#endif
187 +#if __has_feature(modules)
188 +#if __has_warning("-Watimport-in-framework-header")
189 +#pragma clang diagnostic ignored "-Watimport-in-framework-header"
190 +#endif
191 +@import Foundation;
192 +@import ObjectiveC;
193 +#endif
194 +
195 +#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
196 +#pragma clang diagnostic ignored "-Wduplicate-method-arg"
197 +#if __has_warning("-Wpragma-clang-attribute")
198 +# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
199 +#endif
200 +#pragma clang diagnostic ignored "-Wunknown-pragmas"
201 +#pragma clang diagnostic ignored "-Wnullability"
202 +
203 +#if __has_attribute(external_source_symbol)
204 +# pragma push_macro("any")
205 +# undef any
206 +# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="WarplySDKFrameworkIOS",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
207 +# pragma pop_macro("any")
208 +#endif
209 +
210 +@class UIView;
211 +@class NSString;
212 +@class UIViewController;
213 +
214 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS21CampaignViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
215 +@interface CampaignViewInterface : NSObject
216 ++ (UIViewController * _Nonnull)campaignViewController:(UIView * _Nullable)parentView :(NSString * _Nullable)campaign SWIFT_WARN_UNUSED_RESULT;
217 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
218 +@end
219 +
220 +
221 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS26CouponBarcodeViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
222 +@interface CouponBarcodeViewInterface : NSObject
223 ++ (UIViewController * _Nonnull)couponBarcodeViewController:(UIView * _Nullable)parentView :(NSDictionary<NSString *, id> * _Nonnull)coupon SWIFT_WARN_UNUSED_RESULT;
224 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
225 +@end
226 +
227 +
228 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS19CouponViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
229 +@interface CouponViewInterface : NSObject
230 ++ (UIViewController * _Nonnull)couponViewController:(UIView * _Nullable)parentView :(NSDictionary<NSString *, id> * _Nonnull)coupon SWIFT_WARN_UNUSED_RESULT;
231 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
232 +@end
233 +
234 +
235 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS20CouponsViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
236 +@interface CouponsViewInterface : NSObject
237 ++ (UIViewController * _Nonnull)couponsViewController:(UIView * _Nullable)parentView SWIFT_WARN_UNUSED_RESULT;
238 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
239 +@end
240 +
241 +
242 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS18GiftsViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
243 +@interface GiftsViewInterface : NSObject
244 ++ (UIViewController * _Nonnull)giftsViewController:(UIView * _Nullable)parentView SWIFT_WARN_UNUSED_RESULT;
245 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
246 +@end
247 +
248 +
249 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS23MoreForYouViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
250 +@interface MoreForYouViewInterface : NSObject
251 ++ (UIViewController * _Nonnull)moreForYouViewController:(UIView * _Nullable)parentView SWIFT_WARN_UNUSED_RESULT;
252 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
253 +@end
254 +
255 +
256 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS19WalletViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
257 +@interface WalletViewInterface : NSObject
258 ++ (UIViewController * _Nonnull)walletViewController:(UIView * _Nullable)parentView SWIFT_WARN_UNUSED_RESULT;
259 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
260 +@end
261 +
262 +#if __has_attribute(external_source_symbol)
263 +# pragma clang attribute pop
264 +#endif
265 +#pragma clang diagnostic pop
266 +#endif
No preview for this file type
1 +framework module WarplySDKFrameworkIOS {
2 + umbrella header "WarplySDKFrameworkIOS.h"
3 +
4 + export *
5 + module * { export * }
6 +}
7 +
8 +module WarplySDKFrameworkIOS.Swift {
9 + header "WarplySDKFrameworkIOS-Swift.h"
10 + requires objc
11 +}
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 +<plist version="1.0">
4 +<dict>
5 + <key>files</key>
6 + <dict>
7 + <key>Assets.car</key>
8 + <data>
9 + hIFOJQscEXiQ4XMyvuCRGL1zLCg=
10 + </data>
11 + <key>Headers/MyApi.h</key>
12 + <data>
13 + TmDy/fb2haH2GJeGk04vTk9qbQA=
14 + </data>
15 + <key>Headers/WarplySDKFrameworkIOS-Swift.h</key>
16 + <data>
17 + bxZdepR/AgDlquvBbAf1tyeFgHs=
18 + </data>
19 + <key>Headers/WarplySDKFrameworkIOS.h</key>
20 + <data>
21 + K4p760R6wETJ3dCAo5mmJHRMOc8=
22 + </data>
23 + <key>Info.plist</key>
24 + <data>
25 + 9fWTLEQ9fqB0XaebdejrWsTedpk=
26 + </data>
27 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
28 + <data>
29 + AsaK0vYjU7NZwnZZ3Xr8nSbFKFk=
30 + </data>
31 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64.swiftsourceinfo</key>
32 + <data>
33 + AsaK0vYjU7NZwnZZ3Xr8nSbFKFk=
34 + </data>
35 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftdoc</key>
36 + <data>
37 + 34uDVHaK3paKrQvjkXTegENBo+8=
38 + </data>
39 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftmodule</key>
40 + <data>
41 + gRIwC7oHIylawAt386jTddyfBPQ=
42 + </data>
43 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftdoc</key>
44 + <data>
45 + 34uDVHaK3paKrQvjkXTegENBo+8=
46 + </data>
47 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftmodule</key>
48 + <data>
49 + gRIwC7oHIylawAt386jTddyfBPQ=
50 + </data>
51 + <key>Modules/module.modulemap</key>
52 + <data>
53 + ha7ajEHIL6YE8KZ+4J/7MEDFDeQ=
54 + </data>
55 + <key>WLNativeAdCollectionViewCell.nib</key>
56 + <data>
57 + JpqcaqCHDLpEU0KqWMdaJnLZFLo=
58 + </data>
59 + <key>WLNativeAdTableViewCell.nib</key>
60 + <data>
61 + zZf6YWPmGYg525K3h6ctM+J67Gg=
62 + </data>
63 + <key>WLNativeVideoTableViewCell.nib</key>
64 + <data>
65 + QteeSEraaE/Rjil0rTcqFrUGRo0=
66 + </data>
67 + <key>ic_back.png</key>
68 + <data>
69 + WV/loTmJPkI/qJ62+ZvSx90zfuU=
70 + </data>
71 + <key>warp_white_back_button.png</key>
72 + <data>
73 + pv84pocjm3eAQq5wlCXc8R7ebyc=
74 + </data>
75 + <key>warp_white_back_button@2x.png</key>
76 + <data>
77 + oNR6mR20xRiKRlqAH/oO7bnXfbE=
78 + </data>
79 + <key>warp_white_close_button.png</key>
80 + <data>
81 + x2z+5O0GbOC4ZR5CRPg3vzjwU7g=
82 + </data>
83 + <key>warp_white_close_button@2x.png</key>
84 + <data>
85 + ZILm2ke1L8x4S6lKcRq4GJ+RoxY=
86 + </data>
87 + <key>warp_white_forward_button.png</key>
88 + <data>
89 + utaioQ40BK8eYPCmCZtfCkHfjxg=
90 + </data>
91 + <key>warp_white_forward_button@2x.png</key>
92 + <data>
93 + tH1io/Dscj0kbiukAcTCV3McTy0=
94 + </data>
95 + </dict>
96 + <key>files2</key>
97 + <dict>
98 + <key>Assets.car</key>
99 + <dict>
100 + <key>hash2</key>
101 + <data>
102 + pla6bvv1/uIpRTqtTPIg8Mew7QpsSbOAmpUKxNJeEm4=
103 + </data>
104 + </dict>
105 + <key>Headers/MyApi.h</key>
106 + <dict>
107 + <key>hash2</key>
108 + <data>
109 + 2CnZtEzw6XFQKogiT1997Wvv7/18KJliPibaB5yk1+8=
110 + </data>
111 + </dict>
112 + <key>Headers/WarplySDKFrameworkIOS-Swift.h</key>
113 + <dict>
114 + <key>hash2</key>
115 + <data>
116 + XUU+CiYNzR9foAlHuQsWXZ+/a08ja4J/nu4PNEYiJsQ=
117 + </data>
118 + </dict>
119 + <key>Headers/WarplySDKFrameworkIOS.h</key>
120 + <dict>
121 + <key>hash2</key>
122 + <data>
123 + vzJVcnjXgi6I7JknI81AWPBmBkpWBqV47pSppt4U80Q=
124 + </data>
125 + </dict>
126 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
127 + <dict>
128 + <key>hash2</key>
129 + <data>
130 + NBY0sGCovFYN5NXkDj6sv9B7A2rtBIG54mgbS6vQkZQ=
131 + </data>
132 + </dict>
133 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64.swiftsourceinfo</key>
134 + <dict>
135 + <key>hash2</key>
136 + <data>
137 + NBY0sGCovFYN5NXkDj6sv9B7A2rtBIG54mgbS6vQkZQ=
138 + </data>
139 + </dict>
140 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftdoc</key>
141 + <dict>
142 + <key>hash2</key>
143 + <data>
144 + zA+tUoDC+x68aAXxqBeUvGv2iJ7htVDvagoTiEzIxQk=
145 + </data>
146 + </dict>
147 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftmodule</key>
148 + <dict>
149 + <key>hash2</key>
150 + <data>
151 + do2u2n580LpD/BsdvCO5VJdeDyMhvKBPYAKuFu2APpY=
152 + </data>
153 + </dict>
154 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftdoc</key>
155 + <dict>
156 + <key>hash2</key>
157 + <data>
158 + zA+tUoDC+x68aAXxqBeUvGv2iJ7htVDvagoTiEzIxQk=
159 + </data>
160 + </dict>
161 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftmodule</key>
162 + <dict>
163 + <key>hash2</key>
164 + <data>
165 + do2u2n580LpD/BsdvCO5VJdeDyMhvKBPYAKuFu2APpY=
166 + </data>
167 + </dict>
168 + <key>Modules/module.modulemap</key>
169 + <dict>
170 + <key>hash2</key>
171 + <data>
172 + WoUv3VxFCIOkz8D0t9OKGWoJvuudrgR/68KRVl1Yp6E=
173 + </data>
174 + </dict>
175 + <key>WLNativeAdCollectionViewCell.nib</key>
176 + <dict>
177 + <key>hash2</key>
178 + <data>
179 + 8zDmyYpy6RMFwd0JkLUlw7xzmtAZemgGKVmEzODdps4=
180 + </data>
181 + </dict>
182 + <key>WLNativeAdTableViewCell.nib</key>
183 + <dict>
184 + <key>hash2</key>
185 + <data>
186 + xtEvcJFiBXZcOI7/FHyU8BlACL5NoBjwKhXInWyZmf4=
187 + </data>
188 + </dict>
189 + <key>WLNativeVideoTableViewCell.nib</key>
190 + <dict>
191 + <key>hash2</key>
192 + <data>
193 + O1XoZW1GttwSIMwLp6MOHlGlfC1fFYbX4/FtVo47/H8=
194 + </data>
195 + </dict>
196 + <key>ic_back.png</key>
197 + <dict>
198 + <key>hash2</key>
199 + <data>
200 + KNgJyM13gK74GisuM8Zv7dqaymiHG/pNv2L1jncHk68=
201 + </data>
202 + </dict>
203 + <key>warp_white_back_button.png</key>
204 + <dict>
205 + <key>hash2</key>
206 + <data>
207 + WtLlGv8JSOkZku+rqKQw/tx/13nq8Qky49HihuGPap4=
208 + </data>
209 + </dict>
210 + <key>warp_white_back_button@2x.png</key>
211 + <dict>
212 + <key>hash2</key>
213 + <data>
214 + penUjNbdAPoMhsEppAckdM0XIU010PN+jLMPzJG4QRM=
215 + </data>
216 + </dict>
217 + <key>warp_white_close_button.png</key>
218 + <dict>
219 + <key>hash2</key>
220 + <data>
221 + X4A7Fpb03zzFpEdgF+ogLodSWFSO18v722IwMODWIYo=
222 + </data>
223 + </dict>
224 + <key>warp_white_close_button@2x.png</key>
225 + <dict>
226 + <key>hash2</key>
227 + <data>
228 + tNJ1aHwwf1aJWyA+odp5lRaBORb3sMSSVx245FPkGog=
229 + </data>
230 + </dict>
231 + <key>warp_white_forward_button.png</key>
232 + <dict>
233 + <key>hash2</key>
234 + <data>
235 + jrGN5n5MQ6X1nukL28B9bjP9y1MyYVkVI/ku12SFrVE=
236 + </data>
237 + </dict>
238 + <key>warp_white_forward_button@2x.png</key>
239 + <dict>
240 + <key>hash2</key>
241 + <data>
242 + 63yr7MF/rShpUW8P/RtOFP3ua9pbGuuD9cWAFIIutIs=
243 + </data>
244 + </dict>
245 + </dict>
246 + <key>rules</key>
247 + <dict>
248 + <key>^.*</key>
249 + <true/>
250 + <key>^.*\.lproj/</key>
251 + <dict>
252 + <key>optional</key>
253 + <true/>
254 + <key>weight</key>
255 + <real>1000</real>
256 + </dict>
257 + <key>^.*\.lproj/locversion.plist$</key>
258 + <dict>
259 + <key>omit</key>
260 + <true/>
261 + <key>weight</key>
262 + <real>1100</real>
263 + </dict>
264 + <key>^Base\.lproj/</key>
265 + <dict>
266 + <key>weight</key>
267 + <real>1010</real>
268 + </dict>
269 + <key>^version.plist$</key>
270 + <true/>
271 + </dict>
272 + <key>rules2</key>
273 + <dict>
274 + <key>.*\.dSYM($|/)</key>
275 + <dict>
276 + <key>weight</key>
277 + <real>11</real>
278 + </dict>
279 + <key>^(.*/)?\.DS_Store$</key>
280 + <dict>
281 + <key>omit</key>
282 + <true/>
283 + <key>weight</key>
284 + <real>2000</real>
285 + </dict>
286 + <key>^.*</key>
287 + <true/>
288 + <key>^.*\.lproj/</key>
289 + <dict>
290 + <key>optional</key>
291 + <true/>
292 + <key>weight</key>
293 + <real>1000</real>
294 + </dict>
295 + <key>^.*\.lproj/locversion.plist$</key>
296 + <dict>
297 + <key>omit</key>
298 + <true/>
299 + <key>weight</key>
300 + <real>1100</real>
301 + </dict>
302 + <key>^Base\.lproj/</key>
303 + <dict>
304 + <key>weight</key>
305 + <real>1010</real>
306 + </dict>
307 + <key>^Info\.plist$</key>
308 + <dict>
309 + <key>omit</key>
310 + <true/>
311 + <key>weight</key>
312 + <real>20</real>
313 + </dict>
314 + <key>^PkgInfo$</key>
315 + <dict>
316 + <key>omit</key>
317 + <true/>
318 + <key>weight</key>
319 + <real>20</real>
320 + </dict>
321 + <key>^embedded\.provisionprofile$</key>
322 + <dict>
323 + <key>weight</key>
324 + <real>20</real>
325 + </dict>
326 + <key>^version\.plist$</key>
327 + <dict>
328 + <key>weight</key>
329 + <real>20</real>
330 + </dict>
331 + </dict>
332 +</dict>
333 +</plist>
1 Pod::Spec.new do |spec| 1 Pod::Spec.new do |spec|
2 -
3 spec.name = "WarplySDKFrameworkIOS" 2 spec.name = "WarplySDKFrameworkIOS"
4 spec.version = "0.0.1" 3 spec.version = "0.0.1"
5 spec.summary = "A framework used for several functionalities." 4 spec.summary = "A framework used for several functionalities."
6 -
7 spec.description = "This is the Warply framework used for react native or swift apps for analytics, push notifications and the functionality of the app." 5 spec.description = "This is the Warply framework used for react native or swift apps for analytics, push notifications and the functionality of the app."
8 -
9 spec.homepage = "https://git.warp.ly/open-source/warply_sdk_framework.git" 6 spec.homepage = "https://git.warp.ly/open-source/warply_sdk_framework.git"
10 -
11 spec.license = { 7 spec.license = {
12 :type => 'MIT', 8 :type => 'MIT',
13 :file => 'WarplySDKFrameworkIOS/LICENSE.txt' 9 :file => 'WarplySDKFrameworkIOS/LICENSE.txt'
14 } 10 }
15 -
16 spec.author = { "billy" => "skourasbl@gmail.com" } 11 spec.author = { "billy" => "skourasbl@gmail.com" }
17 12
18 spec.platform = :ios, "13.0" 13 spec.platform = :ios, "13.0"
19 -
20 spec.source = { :git => "https://git.warp.ly/open-source/warply_sdk_framework.git", :tag => "0.0.1" } 14 spec.source = { :git => "https://git.warp.ly/open-source/warply_sdk_framework.git", :tag => "0.0.1" }
21 - 15 + spec.public_header_files = "WarplySDKFrameworkIOS.framework/Headers/*.h"
22 - spec.source_files = 'WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets', "WarplySDKFrameworkIOS/*.png", "WarplySDKFrameworkIOS/*.xcassets", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets","WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/**/*.{h,m}", "WarplySDKFrameworkIOS/*.swift", "*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", 'WarplySDKFrameworkIOS/UIResources/*.png', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/UIResources/*.png' 16 + # spec.source_files = 'WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets', "WarplySDKFrameworkIOS/*.png", "WarplySDKFrameworkIOS/*.xcassets", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets","WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/**/*.{h,m}", "WarplySDKFrameworkIOS/*.swift", "*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", 'WarplySDKFrameworkIOS/UIResources/*.png', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/UIResources/*.png'
23 spec.exclude_files = "Classes/Exclude" 17 spec.exclude_files = "Classes/Exclude"
24 - 18 + spec.source_files = "WarplySDKFrameworkIOS.framework/Headers/*.h"
25 - spec.resource_bundles = { 19 + spec.vendored_frameworks = "WarplySDKFrameworkIOS.framework"
26 - 'Resources' => ['WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets'] 20 + # spec.resource_bundles = {
27 - } 21 + # 'Resources' => ['WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets']
28 - spec.preserve_paths = 'WarplySDKFrameworkIOS/myApi.h', 'WarplySDKFrameworkIOS/swiftApi.swift' 22 + # }
29 - spec.vendored_libraries = 'WarplySDKFrameworkIOS/myApi.h', 'WarplySDKFrameworkIOS/swiftApi.swift' 23 + # spec.preserve_paths = 'WarplySDKFrameworkIOS/myApi.h'
30 - spec.ios.deployment_target = '13.0' 24 + # spec.vendored_libraries = 'WarplySDKFrameworkIOS/myApi.h'
31 - spec.frameworks = 'UIKit', 'Foundation' 25 + # spec.ios.deployment_target = '13.0'
32 - spec.requires_arc = true 26 + # spec.frameworks = 'UIKit', 'Foundation'
33 - spec.subspec 'WarplySDKFrameworkIOS' do |mylib| 27 + # spec.requires_arc = true
34 - mylib.source_files = 'WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets', "WarplySDKFrameworkIOS/*.png", "WarplySDKFrameworkIOS/*.xcassets", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets","WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/**/*.{h,m}", "WarplySDKFrameworkIOS/*.swift", "*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", 'WarplySDKFrameworkIOS/UIResources/*.png', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/UIResources/*.png' 28 + # spec.subspec 'WarplySDKFrameworkIOS' do |mylib|
35 - mylib.vendored_frameworks = 'WarplySDKFrameworkIOS/Frameworks/WarplySDKFrameworkIOS.framework' 29 + # mylib.source_files = 'WarplySDKFrameworkIOS/*.xcassets', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets', "WarplySDKFrameworkIOS/*.png", "WarplySDKFrameworkIOS/*.xcassets", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xcassets","WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.xib", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/*.{h,m}", "WarplySDKFrameworkIOS/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/*.{h,m}", "WarplySDKFrameworkIOS/**/**/**/*.{h,m}", "WarplySDKFrameworkIOS/*.swift", "*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", "WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/*.swift", 'WarplySDKFrameworkIOS/UIResources/*.png', 'WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/UIResources/*.png'
36 - end 30 + # mylib.vendored_frameworks = 'WarplySDKFrameworkIOS/Frameworks/WarplySDKFrameworkIOS.framework'
37 - 31 + # end
38 -end 32 +end
...\ No newline at end of file ...\ No newline at end of file
......
No preview for this file type
1 -//
2 -// WarplyEvents.h
3 -// App
4 -//
5 -// Created by Fotios Kalaitzidis on 23/10/2018.
6 -// Copyright © 2018 Facebook. All rights reserved.
7 -//
8 -#import <Foundation/Foundation.h>
9 -
10 -@interface WarplyReactMethods : NSObject
11 -
12 -@end
1 -//
2 -// WarplyEvents.m
3 -// App
4 -//
5 -// Created by Fotios Kalaitzidis on 23/10/2018.
6 -// Copyright © 2018 Facebook. All rights reserved.
7 -//
8 -
9 -#import "WarplyReactMethods.h"
10 -#import "WLUserManager.h"
11 -#import "WLAnalyticsManager.h"
12 -#import "Warply.h"
13 -#import <AdSupport/AdSupport.h>
14 -
15 -@implementation WarplyReactMethods
16 -- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority {
17 - NSString *event_Name = eventName;
18 - NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];
19 - NSDictionary *inapp_event = [NSDictionary dictionaryWithObjectsAndKeys:event_Name, @"event_id", nil, @"page_id", time_submitted, @"time_submitted", nil, @"action_metadata", nil];
20 - NSDictionary *eventContext = [NSDictionary dictionaryWithObject:inapp_event forKey:@"inapp_analytics"];
21 - WLEventSimple *simpleEvent = [[WLEventSimple alloc] initWithType:@"inapp_analytics" andContext:eventContext];
22 -
23 - [[Warply sharedService] addEvent:simpleEvent priority:priority];
24 -}
25 -
26 -- (NSString *) getUniqueId {
27 - return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
28 -}
29 -
30 -
31 -- (NSString *) getAdvertisementId {
32 - return [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
33 -}
34 -
35 -
36 -@end
1 -MIT License
2 -Copyright © 2018 Matan Cohen
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -The above copyright notice and this permission notice shall be included in all
10 -copies or substantial portions of the Software.
11 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 -SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "info" : {
3 - "author" : "xcode",
4 - "version" : 1
5 - }
6 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "coupon_bg.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "coupon_bg-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "coupon_bg-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "coupons_container.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "coupons_container-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "coupons_container-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "coupons_scrollview.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "coupons_scrollview-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "coupons_scrollview-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "filters_btn.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "filters_btn-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "filters_btn-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "ic_back.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "ic_back-2.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "ic_back-1.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "location_icon.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "location_icon-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "location_icon-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "logo.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "logo-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "logo-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -{
2 - "images" : [
3 - {
4 - "filename" : "search_icon.png",
5 - "idiom" : "universal",
6 - "scale" : "1x"
7 - },
8 - {
9 - "filename" : "search_icon-1.png",
10 - "idiom" : "universal",
11 - "scale" : "2x"
12 - },
13 - {
14 - "filename" : "search_icon-2.png",
15 - "idiom" : "universal",
16 - "scale" : "3x"
17 - }
18 - ],
19 - "info" : {
20 - "author" : "xcode",
21 - "version" : 1
22 - }
23 -}
1 -# Uncomment the next line to define a global platform for your project
2 -# platform :ios, '9.0'
3 -
4 -target 'WarplySDKFrameworkIOS' do
5 - # Comment the next line if you don't want to use dynamic frameworks
6 - use_frameworks!
7 -
8 - # Pods for WarplySDKFrameworkIOS
9 -
10 -end
1 -PODFILE CHECKSUM: 469e9ad6db6643e917950516ae5b80abb382aab0
2 -
3 -COCOAPODS: 1.11.2
No preview for this file type
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -/*!
27 - @header WLEvent.h
28 - The WLEvent provides a functional interface for Warply events.
29 - Use the methods declared here to initialise and create events with arbitrary
30 - context and type.
31 - @copyright Warply Inc.
32 - */
33 -#import <Foundation/Foundation.h>
34 -
35 -/*!
36 - @class WLEvent
37 - @discussion This class provides methods for creating an event with arbitrary
38 - context.
39 - */
40 -@interface WLEvent : NSObject
41 -{
42 -@protected
43 - NSString *_time;
44 - NSMutableDictionary *_data;
45 -}
46 -
47 -/*!
48 - @methodgroup Class Methods
49 - @discussion Convinience class methods for initialising an event.
50 - */
51 -/*!
52 - @abstract Creates an event.
53 - @discussion Initializes and returns a newly allocated WLEvent object.
54 - Initializes and returns a newly allocated WLEvent object.
55 - @return Returns WLEvent object.
56 - */
57 -+ (id)event;
58 -/*!
59 - @abstract Creates an event with arbitrary context.
60 - @discussion Initializes and returns a newly allocated WLEvent object with the
61 - arbitrary context.
62 - @param context A dictionary object with arbitrary key-value entries.
63 - @return Returns WLEvent object.
64 - */
65 -+ (id)eventWithContext:(NSDictionary*)context;
66 -
67 -/*!
68 - @property time
69 - @abstract A string with event created time in epoch format. Read only property.
70 - */
71 -@property (nonatomic, readonly) NSString *time;
72 -/*!
73 - @property data
74 - @abstract A dictionary with event context. Read only property.
75 - */
76 -@property (nonatomic, readonly) NSMutableDictionary *data;
77 -
78 -/*!
79 - @methodgroup Initialising Event
80 - */
81 -/*!
82 - @abstract Initialise an WLevent object.
83 - @discussion Initializes and returns a newly allocated WLEvent object with the
84 - arbitrary context.
85 - @param context A dictionary object with arbitrary key-value entries.
86 - @return Returns WLEvent object.
87 - */
88 -- (id)initWithContext:(NSDictionary*)context;
89 -/*!
90 - @methodgroup Getting Event Type
91 - */
92 -/*!
93 - @abstract Get event type.
94 - @discussion This method returns the type of the event.
95 - @return Returns a string object with event type.
96 - */
97 -- (NSString *)getType;
98 -/*!
99 - @methodgroup Adding Context to Event
100 - */
101 -/*!
102 - @abstract Add context to event.
103 - @discussion This method adds a key-value pair to existing context of an event.
104 - @param value An id object with the value of the key.
105 - @param key A string object with the key of the value.
106 - */
107 -- (void)addDataWithValue:(id)value forKey:(NSString*)key;
108 -
109 -@end
110 -
111 -/*!
112 - @class WLEventSimple
113 - @discussion This class provides methods for creating an event with arbitrary
114 - context and type.
115 - */
116 -@interface WLEventSimple : WLEvent
117 -{
118 -@private
119 - NSString *_type;
120 -}
121 -
122 -/*!
123 - @methodgroup Class Methods
124 - @discussion Convinience class methods for initialising an event.
125 - */
126 -/*!
127 - @abstract Creates an event with arbitrary type.
128 - @discussion Initializes and returns a newly allocated WLEventSimple object
129 - with arbitrary type.
130 - @param aType A string object with the event type.
131 - @return Returns WLEvent object.
132 - */
133 -+ (id)eventWithType:(NSString*)aType;
134 -/*!
135 - @abstract Creates an event with arbitrary type and context.
136 - @discussion Initializes and returns a newly allocated WLEventSimple object
137 - with arbitrary type and context.
138 - @param aType A string object with the event type.
139 - @param context A dictionary with arbitrary context.
140 - @return Returns WLEvent object.
141 - */
142 -+ (id)eventWithType:(NSString*)aType andContext:(NSDictionary*)context;
143 -
144 -/*!
145 - @methodgroup Initialising Event
146 - */
147 -/*!
148 - @abstract Initialise an event with arbitrary type.
149 - @discussion Initializes and returns a newly allocated WLEvent object with the
150 - arbitrary type.
151 - @param aType A string object with the event type.
152 - @return Returns WLEvent object.
153 - */
154 -- (id)initWithType:(NSString*)aType;
155 -/*!
156 - @abstract Initialise an event with arbitrary type and context.
157 - @discussion Initializes and returns a newly allocated WLEvent object with the
158 - arbitrary type and context.
159 - @param aType A string object with the event type.
160 - @param context A dictionary with arbitrary context.
161 - @return Returns WLEvent object.
162 - */
163 -- (id)initWithType:(NSString*)aType andContext:(NSDictionary*)context;
164 -
165 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import "WLEvent.h"
27 -#import "WLGlobals.h"
28 -
29 -@interface WLEvent()
30 -
31 -- (void)gatherIndividualData:(NSDictionary*)context;
32 -- (void)gatherData:(NSDictionary*)context;
33 -
34 -@end
35 -
36 -@implementation WLEvent
37 -
38 -@synthesize time = _time;
39 -@synthesize data = _data;
40 -
41 -#pragma mark - Static Methods
42 -///////////////////////////////////////////////////////////////////////////////////////////////////
43 -+ (id)event
44 -{
45 -#if ! __has_feature(objc_arc)
46 - return [[[self alloc] init] autorelease];
47 -#else
48 - return [[self alloc] init];
49 -#endif
50 -}
51 -
52 -///////////////////////////////////////////////////////////////////////////////////////////////////
53 -+ (id)eventWithContext:(NSDictionary*)context
54 -{
55 -#if ! __has_feature(objc_arc)
56 - return [[[self alloc] initWithContext:context] autorelease];
57 -#else
58 - return [[self alloc] initWithContext:context];
59 -#endif
60 -}
61 -
62 -#pragma mark - Initialization
63 -///////////////////////////////////////////////////////////////////////////////////////////////////
64 -- (id)init
65 -{
66 - self = [super init];
67 - if (self) {
68 - _data = [NSMutableDictionary new];
69 - }
70 -
71 - return self;
72 -}
73 -
74 -///////////////////////////////////////////////////////////////////////////////////////////////////
75 -- (id)initWithContext:(NSDictionary*)context
76 -{
77 - self = [self init];
78 - if (self) {
79 - [self gatherData:context];
80 - }
81 -
82 - return self;
83 -}
84 -
85 -#pragma mark - Public Methods
86 -///////////////////////////////////////////////////////////////////////////////////////////////////
87 -- (NSString*)getType
88 -{
89 - return @"base";
90 -}
91 -
92 -///////////////////////////////////////////////////////////////////////////////////////////////////
93 -- (void)addDataWithValue:(id)value forKey:(NSString*)key
94 -{
95 - if (value && key)
96 - [_data setObject:value forKey:key];
97 -}
98 -
99 -#pragma mark - Private Methods
100 -///////////////////////////////////////////////////////////////////////////////////////////////////
101 -- (void)gatherIndividualData:(NSDictionary*)context { }
102 -
103 -///////////////////////////////////////////////////////////////////////////////////////////////////
104 -- (void)gatherData:(NSDictionary*)context {
105 - // in case we re-use a event object
106 - _time = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]];
107 - [_data removeAllObjects];
108 -
109 - // gather individual data
110 - [self gatherIndividualData:context];
111 -}
112 -
113 -@end
114 -
115 -///////////////////////////////////////////////////////////////////////////////////////////////////
116 -@implementation WLEventSimple
117 -
118 -#pragma mark - Static Methods
119 -///////////////////////////////////////////////////////////////////////////////////////////////////
120 -+ (id)eventWithType:(NSString*)aType
121 -{
122 - return [[self alloc] initWithType:aType];
123 -}
124 -
125 -///////////////////////////////////////////////////////////////////////////////////////////////////
126 -+ (id)eventWithType:(NSString*)aType andContext:(NSDictionary*)context
127 -{
128 - return [[self alloc] initWithType:aType andContext:context];
129 -}
130 -
131 -#pragma mark - Initialization
132 -///////////////////////////////////////////////////////////////////////////////////////////////////
133 -- (id)initWithType:(NSString*)aType
134 -{
135 - self=[super init];
136 - if (self) {
137 - _type = aType;
138 - }
139 - return self;
140 -}
141 -
142 -///////////////////////////////////////////////////////////////////////////////////////////////////
143 -- (id)initWithType:(NSString*)aType andContext:(NSDictionary*)context
144 -{
145 - self = [super initWithContext:context];
146 - if (self) {
147 - _type = aType;
148 - }
149 -
150 - return self;
151 -}
152 -
153 -#pragma mark - Public Methods
154 -///////////////////////////////////////////////////////////////////////////////////////////////////
155 -- (NSString*)getType
156 -{
157 - return _type;
158 -}
159 -
160 -#pragma mark - Override Methods
161 -///////////////////////////////////////////////////////////////////////////////////////////////////
162 -- (void)gatherIndividualData:(NSDictionary*)context
163 -{
164 - WLLOG(@"WLEvent Context: %@", context);
165 - [_data addEntriesFromDictionary:context];
166 -}
167 -
168 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -///////////////////////////////////////////////////////////////////////////////
27 -// Base URL
28 -//#define WARP_PRODUCTION_BASE_URL @"https://engage-stage.warp.ly"
29 -//#define WARP_HOST @"engage-stage.warp.ly"
30 -//#define WARP_ERROR_DOMAIN @"engage-stage.warp.ly"
31 -extern NSString* WARP_PRODUCTION_BASE_URL;
32 -extern NSString* WARP_HOST;
33 -extern NSString* WARP_ERROR_DOMAIN;
34 -extern NSString* MERCHANT_ID;
35 -extern NSString* LANG;
36 -#define WARP_PAGE_URL_FORMAT @"%@/api/session/%@"
37 -#define WARP_IMAGE_URL_FORMAT @"%@/api/session/logo/%@"
38 -
39 -///////////////////////////////////////////////////////////////////////////////
40 -// Settings
41 -#ifdef _WL_VERSION
42 -#define WL_VERSION @ _WL_VERSION
43 -#else
44 -#define WL_VERSION @ "3.2.0a"
45 -#endif
46 -
47 -#define GEOFENCING_POIS_ENABLED @"GEOFENCING_POIS_ENABLED"
48 -#define WL_IOS_LOCATION_FOREGROUND_MODE @"IOS_LOCATION_FOREGROUND_MODE"
49 -#define WL_IOS_LOCATION_BACKGROUND_MODE @"IOS_LOCATION_BACKGROUND_MODE"
50 -#define WL_IOS_GEOFENCING_ENABLED @"IOS_GEOFENCING_ENABLED"
51 -#define WL_IOS_FOREGROUND_DISTANCE_FILTER @"IOS_FOREGROUND_DISTANCE_FILTER"
52 -#define WL_IOS_BACKGROUND_DISTANCE_FILTER @"IOS_BACKGROUND_DISTANCE_FILTER"
53 -#define WL_DEVICE_INFO_ENABLED @"DEVICE_INFO_ENABLED"
54 -#define WL_OFFERS_ENABLED @"OFFERS_ENABLED"
55 -#define WL_CONSUMER_DATA_ENABLED @"CONSUMER_DATA_ENABLED"
56 -#define WL_USER_SESSION_ENABLED @"USER_SESSION_ENABLED"
57 -#define WL_CUSTOM_ANALYTICS_ENABLED @"CUSTOM_ANALYTICS_ENABLED"
58 -#define WL_USER_TAGGING_ENABLED @"USER_TAGGING_ENABLED"
59 -#define WL_APPLICATION_DATA_ENABLED @"APPLICATION_DATA_ENABLED"
60 -#define WL_WARPLY_ENABLED @"WARPLY_ENABLED"
61 -#define WL_FEATURES_CHECK_INTERVAL @"FEATURES_CHECK_INTERVAL"
62 -#define WL_LIFECYCLE_ANALYTICS_ENABLED @"LIFECYCLE_ANALYTICS_ENABLED"
63 -#define WL_IOS_LOCATION_FOREGROUND_DESIRED_ACCURACY @"IOS_LOCATION_FOREGROUND_DESIRED_ACCURACY"
64 -#define WL_IOS_LOCATION_BACKGROUND_DESIRED_ACCURACY @"IOS_LOCATION_BACKGROUND_DESIRED_ACCURACY"
65 -#define WL_IOS_DEVICE_IS_WARPED @"is_warped"
66 -#define WL_IOS_DEVICE_HAS_DEVICE_INFO @"has_device_info"
67 -#define WL_IOS_DEVICE_HAS_APPLICATION_INFO @"has_application_info"
68 -#define WL_FEATURE_IS_DISABLED_WITH_KEY(KEY) \
69 - ([[NSUserDefaults standardUserDefaults] boolForKey:KEY] == NO \
70 - && [[NSUserDefaults standardUserDefaults] objectForKey:KEY] != nil) \
71 -
72 -#define WL_WARP_NOTIFICATIONS_ENABLED @"warp_enabled"
73 -#define WL_APPLICATION_DATA @"application_data"
74 -#define WL_DEVICE_STATUS @"device_status"
75 -#define WL_BEACON_ENABLED @"BEACON_ENABLED"
76 -#define WL_BEACON_TIME_INTERVAL_TO_RESEND @"BEACON_TIME_INTERVAL_TO_RESEND"
77 -
78 -///////////////////////////////////////////////////////////////////////////////
79 -// Logging
80 -#ifdef DEBUG
81 -#define WLLOG(xx, ...) NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
82 -#else
83 -#define WLLOG(xx, ...) ((void)0)
84 -#endif // #ifdef DEBUG
85 -
86 -///////////////////////////////////////////////////////////////////////////////
87 -// Version Interface
88 -#define WL_VERSION_INTERFACE() \
89 -+ (NSString *)get;
90 -
91 -#define WL_VERSION_IMPLEMENTATION(VERSION_STR) \
92 -+ (NSString *)get { \
93 - return VERSION_STR; \
94 -} \
95 -
96 -///////////////////////////////////////////////////////////////////////////////
97 -// System Versioning
98 -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
99 -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
100 -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
101 -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
102 -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
103 -
104 -///////////////////////////////////////////////////////////////////////////////
105 -// Enum Versioning
106 -#ifdef __IPHONE_6_0 // iOS6 and later
107 -# define WLTextAlignmentCenter NSTextAlignmentCenter
108 -# define WLTextAlignmentLeft NSTextAlignmentLeft
109 -# define WLTextAlignmentRight NSTextAlignmentRight
110 -# define WLTextTruncationTail NSLineBreakByTruncatingTail
111 -# define WLTextTruncationMiddle NSLineBreakByWordWrapping
112 -# define WLLineBreakByWordWrapping NSLineBreakByWordWrapping
113 -#else // older versions
114 -# define WLTextAlignmentCenter UITextAlignmentCenter
115 -# define WLTextAlignmentLeft UITextAlignmentLeft
116 -# define WLTextAlignmentRight UITextAlignmentRight
117 -# define WLTextTruncationTail UILineBreakModeTailTruncation
118 -# define WLTextTruncationMiddle UILineBreakModeMiddleTruncation
119 -# define WLLineBreakByWordWrapping UILineBreakModeWordWrap
120 -#endif
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import <Foundation/Foundation.h>
27 -#import <StoreKit/StoreKit.h>
28 -#import "Warply.h"
29 -
30 -@interface WLAPPActionHandler : NSObject <WLActionHandler,SKStoreProductViewControllerDelegate>
31 -
32 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import "WLAPPActionHandler.h"
27 -#import "WLAnalyticsManager.h"
28 -#import "WLInboxItemViewController.h"
29 -#import "NSString+SSToolkitAdditions.h"
30 -#import "UIViewController+WLAdditions.h"
31 -
32 -@interface WLAPPActionHandler ()
33 -
34 -@property (nonatomic, assign) WLInboxItemViewController *inboxVC;
35 -@property (nonatomic) BOOL *loadingProduct;
36 -@end
37 -
38 -
39 -@implementation WLAPPActionHandler
40 -
41 -#pragma mark - Static Methods
42 -////////////////////////////////////////////////////////////////////////////////
43 -- (BOOL)canHandleActionUrl:(NSURL *)url
44 -{
45 - return [url.scheme isEqualToString: @"itms-apps"];
46 -}
47 -
48 -#pragma mark - Override Methods
49 -////////////////////////////////////////////////////////////////////////////////
50 -- (void)handleActionUrl:(NSURL *)url
51 -{
52 - UINavigationController *inboxNavCon = (UINavigationController *)[([UIApplication sharedApplication].delegate).window.rootViewController topModalViewController];
53 - self.inboxVC = [inboxNavCon.viewControllers objectAtIndex:0];
54 -
55 - NSString *appID = nil;
56 -
57 - if ([SKStoreProductViewController class]) {
58 - __block SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
59 - storeViewController.delegate = self;
60 - NSString *escapedResourceSpecifier = [url.resourceSpecifier stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
61 - NSRange appIDRange = [escapedResourceSpecifier rangeOfString:@"id"];
62 - NSRange appQuestionMarkRange = [escapedResourceSpecifier rangeOfString:@"?"];
63 -
64 - if (appIDRange.location != NSNotFound && appQuestionMarkRange.location != NSNotFound) {
65 - appID = [escapedResourceSpecifier substringWithRange:NSMakeRange(appIDRange.location + 2, appQuestionMarkRange.location - (appIDRange.location + 2))];
66 - }
67 -
68 - NSDictionary *parameters = @{SKStoreProductParameterITunesItemIdentifier:[NSNumber numberWithInteger:[appID intValue]]};
69 - [storeViewController loadProductWithParameters:parameters
70 - completionBlock:^(BOOL result, NSError *error) {
71 - if (result) {
72 - [self.inboxVC presentViewController:storeViewController animated:YES completion:nil];
73 - }
74 - }];
75 - } else {
76 - [[UIApplication sharedApplication] openURL:url];
77 - }
78 -
79 - [WLAnalyticsManager logUrgentEventWithEventId:@"NB_CUSTOM_ACTION" pageId:@"APP_DOWNLOAD" actionMetadata:@{@"result":@[@"APPSTORE"], @"session_uuid":self.inboxVC.session_uuid, @"url": [url absoluteString]}];
80 -}
81 -
82 -#pragma mark - SKStoreProductViewControllerDelegate
83 -////////////////////////////////////////////////////////////////////////////////
84 --(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
85 -{
86 - [viewController dismissViewControllerAnimated:YES completion:nil];
87 -}
88 -
89 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import <MessageUI/MessageUI.h>
27 -#import "Warply.h"
28 -
29 -@interface WLSMSActionHandlerDeprecated : NSObject <MFMessageComposeViewControllerDelegate, WLActionHandler>
30 -
31 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import "WLSMSActionHandlerDeprecated.h"
27 -#import "WLGlobals.h"
28 -#import "WLInboxItemViewController.h"
29 -#import "UIViewController+WLAdditions.h"
30 -
31 -@interface WLSMSActionHandlerDeprecated ()
32 -@property (nonatomic , weak) WLInboxItemViewController *inboxVC;
33 -@end
34 -
35 -@implementation WLSMSActionHandlerDeprecated
36 -
37 -#pragma mark - Static Methods
38 -///////////////////////////////////////////////////////////////////////////////////////////////////
39 -- (BOOL)canHandleActionUrl:(NSURL *)url
40 -{
41 - return [[url scheme] isEqualToString: @"rsms"];
42 -}
43 -
44 -#pragma mark - Override Methods
45 -///////////////////////////////////////////////////////////////////////////////////////////////////
46 -- (void)handleActionUrl:(NSURL *)url
47 -{
48 - self.inboxVC = (WLInboxItemViewController *)[([UIApplication sharedApplication].delegate).window.rootViewController topModalViewController];
49 -
50 -
51 - NSArray *args = [url.resourceSpecifier componentsSeparatedByString:@"/"];
52 - if (args == nil)
53 - return;
54 -
55 - if ([args count] < 4)
56 - return;
57 -
58 - MFMessageComposeViewController *smsController = [[MFMessageComposeViewController alloc] init];
59 - @try {
60 - [smsController setRecipients:[NSArray arrayWithObject:[args objectAtIndex:4]]];
61 - //[smsController setBody:[NSString stringWithFormat:@"Hello from %@", BRAND_NAME]];
62 -
63 - if ([args count] > 4) {
64 - NSString *body = [[args objectAtIndex:5] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
65 - [smsController setBody:body];
66 - }
67 -
68 - [smsController setMessageComposeDelegate:self];
69 - [_inboxVC presentViewController:smsController animated:YES completion:nil];
70 - }
71 - @finally {
72 -
73 - }
74 -}
75 -
76 -#pragma mark - MFMessageComposeViewControllerDelegate
77 -///////////////////////////////////////////////////////////////////////////////////////////////////
78 -- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
79 -{
80 - WLInboxItemViewController *inboxItemViewController = (WLInboxItemViewController *)[([UIApplication sharedApplication].delegate).window.rootViewController topModalViewController];
81 - NSString *resultString;
82 - switch (result) {
83 - case MessageComposeResultCancelled:
84 - resultString = @"sms_cancelled";
85 - break;
86 - case MessageComposeResultFailed:
87 - resultString = @"sms_failed";
88 - break;
89 - case MessageComposeResultSent:
90 - resultString = @"sms_sent";
91 - }
92 - [WLAnalyticsManager logEventWithEventId:@"NB_ACTION" pageId:inboxItemViewController.session_uuid actionMetadata:[NSDictionary dictionaryWithObjectsAndKeys:resultString, @"sms_result", self.inboxVC.requestedUrl.absoluteString, @"action_url", nil]];
93 - [controller dismissViewControllerAnimated:YES completion:nil];
94 -}
95 -
96 -@end
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import <MessageUI/MessageUI.h>
27 -#import "Warply.h"
28 -
29 -@interface WLSMSActionHanlder : NSObject <MFMessageComposeViewControllerDelegate, WLActionHandler>
30 -
31 -@end
...\ No newline at end of file ...\ No newline at end of file
1 -/*
2 - Copyright 2010-2016 Warply Inc. All rights reserved.
3 -
4 - Redistribution and use in source and binary forms, without modification,
5 - are permitted provided that the following conditions are met:
6 -
7 - 1. Redistributions of source code must retain the above copyright notice, this
8 - list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binaryform must reproduce the above copyright notice,
11 - this list of conditions and the following disclaimer in the documentation
12 - and/or other materials provided with the distribution.
13 -
14 - THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 - EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 - */
25 -
26 -#import "WLSMSActionHanlder.h"
27 -#import "WLGlobals.h"
28 -#import "WLAnalyticsManager.h"
29 -#import "WLInboxItemViewController.h"
30 -#import "WLBaseItem.h"
31 -#import "UIViewController+WLAdditions.h"
32 -
33 -@interface WLSMSActionHanlder ()
34 -
35 -@property (nonatomic, weak) WLInboxItemViewController *inboxVC;
36 -
37 -@end
38 -
39 -@implementation WLSMSActionHanlder
40 -
41 -#pragma mark - Static Methods
42 -///////////////////////////////////////////////////////////////////////////////////////////////////
43 -- (BOOL)canHandleActionUrl:(NSURL *)url
44 -{
45 - return [url.scheme isEqualToString: @"sms"];
46 -}
47 -
48 -#pragma mark - Override Methods
49 -///////////////////////////////////////////////////////////////////////////////////////////////////
50 -- (void)handleActionUrl:(NSURL *)url
51 -{
52 - UINavigationController *inboxNavCon = (UINavigationController *)[([UIApplication sharedApplication].delegate).window.rootViewController topModalViewController];
53 - self.inboxVC = [inboxNavCon.viewControllers objectAtIndex:0];
54 -
55 - if (![MFMessageComposeViewController canSendText]) {
56 - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"This device does not support text messages", @"Warply") message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"Warply") otherButtonTitles:nil];
57 - [alert show];
58 -
59 - return;
60 - }
61 -
62 - WLLOG(@"SMS URI: %@", url.absoluteString);
63 - if (url.resourceSpecifier == nil) {
64 - return;
65 - }
66 - NSString *escapedResourceSpecifier = [url.resourceSpecifier stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
67 - NSArray *args = [escapedResourceSpecifier componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"?&"]];
68 - NSString *recipientsString = [args objectAtIndex:0];
69 - NSArray *recipients = [recipientsString componentsSeparatedByString:@","];
70 - NSString *bodyString = nil;
71 -
72 - for (NSString *argument in args) {
73 - if ([argument isEqualToString:recipientsString]) {
74 - continue;
75 - }
76 - NSRange bodyKeyRange = [argument rangeOfString:@"body="];
77 - if (bodyKeyRange.location != NSNotFound) {
78 - bodyString = [argument substringFromIndex:bodyKeyRange.length];
79 - }
80 - }
81 -
82 - MFMessageComposeViewController *smsController = [[MFMessageComposeViewController alloc] init];
83 - [smsController setRecipients:recipients];
84 - [smsController setBody:bodyString];
85 -
86 - [smsController setMessageComposeDelegate:self];
87 - [_inboxVC presentViewController:smsController animated:YES completion:nil];
88 -
89 -}
90 -
91 -#pragma mark - MFMessageComposeViewControllerDelegate
92 -///////////////////////////////////////////////////////////////////////////////////////////////////
93 -- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
94 -{
95 - NSArray *results;
96 - switch (result) {
97 - case MessageComposeResultCancelled:
98 - results = @[@"sms_prompt_clicked", @"sms_cancelled"];
99 - break;
100 - case MessageComposeResultFailed:
101 - results = @[@"sms_prompt_clicked", @"sms_failed"];
102 - break;
103 - case MessageComposeResultSent:
104 - results = @[@"sms_prompt_clicked", @"sms_sent"];
105 - }
106 - [WLAnalyticsManager logUrgentEventWithEventId:@"NB_CUSTOM_ACTION" pageId:@"SMS" actionMetadata:@{@"session_uuid": self.inboxVC.session_uuid, @"result":results}];
107 - [controller dismissViewControllerAnimated:YES completion:nil];
108 -}
109 -
110 -@end
1 -// AFNetworkReachabilityManager.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <Foundation/Foundation.h>
23 -
24 -#if !TARGET_OS_WATCH
25 -#import <SystemConfiguration/SystemConfiguration.h>
26 -
27 -typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
28 - AFNetworkReachabilityStatusUnknown = -1,
29 - AFNetworkReachabilityStatusNotReachable = 0,
30 - AFNetworkReachabilityStatusReachableViaWWAN = 1,
31 - AFNetworkReachabilityStatusReachableViaWiFi = 2,
32 -};
33 -
34 -NS_ASSUME_NONNULL_BEGIN
35 -
36 -/**
37 - `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
38 -
39 - Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
40 -
41 - See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
42 -
43 - @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
44 - */
45 -@interface AFNetworkReachabilityManager : NSObject
46 -
47 -/**
48 - The current network reachability status.
49 - */
50 -@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
51 -
52 -/**
53 - Whether or not the network is currently reachable.
54 - */
55 -@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
56 -
57 -/**
58 - Whether or not the network is currently reachable via WWAN.
59 - */
60 -@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
61 -
62 -/**
63 - Whether or not the network is currently reachable via WiFi.
64 - */
65 -@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
66 -
67 -///---------------------
68 -/// @name Initialization
69 -///---------------------
70 -
71 -/**
72 - Returns the shared network reachability manager.
73 - */
74 -+ (instancetype)sharedManager;
75 -
76 -/**
77 - Creates and returns a network reachability manager with the default socket address.
78 -
79 - @return An initialized network reachability manager, actively monitoring the default socket address.
80 - */
81 -+ (instancetype)manager;
82 -
83 -/**
84 - Creates and returns a network reachability manager for the specified domain.
85 -
86 - @param domain The domain used to evaluate network reachability.
87 -
88 - @return An initialized network reachability manager, actively monitoring the specified domain.
89 - */
90 -+ (instancetype)managerForDomain:(NSString *)domain;
91 -
92 -/**
93 - Creates and returns a network reachability manager for the socket address.
94 -
95 - @param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
96 -
97 - @return An initialized network reachability manager, actively monitoring the specified socket address.
98 - */
99 -+ (instancetype)managerForAddress:(const void *)address;
100 -
101 -/**
102 - Initializes an instance of a network reachability manager from the specified reachability object.
103 -
104 - @param reachability The reachability object to monitor.
105 -
106 - @return An initialized network reachability manager, actively monitoring the specified reachability.
107 - */
108 -- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
109 -
110 -/**
111 - * Initializes an instance of a network reachability manager
112 - *
113 - * @return nil as this method is unavailable
114 - */
115 -- (nullable instancetype)init NS_UNAVAILABLE;
116 -
117 -///--------------------------------------------------
118 -/// @name Starting & Stopping Reachability Monitoring
119 -///--------------------------------------------------
120 -
121 -/**
122 - Starts monitoring for changes in network reachability status.
123 - */
124 -- (void)startMonitoring;
125 -
126 -/**
127 - Stops monitoring for changes in network reachability status.
128 - */
129 -- (void)stopMonitoring;
130 -
131 -///-------------------------------------------------
132 -/// @name Getting Localized Reachability Description
133 -///-------------------------------------------------
134 -
135 -/**
136 - Returns a localized string representation of the current network reachability status.
137 - */
138 -- (NSString *)localizedNetworkReachabilityStatusString;
139 -
140 -///---------------------------------------------------
141 -/// @name Setting Network Reachability Change Callback
142 -///---------------------------------------------------
143 -
144 -/**
145 - Sets a callback to be executed when the network availability of the `baseURL` host changes.
146 -
147 - @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
148 - */
149 -- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
150 -
151 -@end
152 -
153 -///----------------
154 -/// @name Constants
155 -///----------------
156 -
157 -/**
158 - ## Network Reachability
159 -
160 - The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
161 -
162 - enum {
163 - AFNetworkReachabilityStatusUnknown,
164 - AFNetworkReachabilityStatusNotReachable,
165 - AFNetworkReachabilityStatusReachableViaWWAN,
166 - AFNetworkReachabilityStatusReachableViaWiFi,
167 - }
168 -
169 - `AFNetworkReachabilityStatusUnknown`
170 - The `baseURL` host reachability is not known.
171 -
172 - `AFNetworkReachabilityStatusNotReachable`
173 - The `baseURL` host cannot be reached.
174 -
175 - `AFNetworkReachabilityStatusReachableViaWWAN`
176 - The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
177 -
178 - `AFNetworkReachabilityStatusReachableViaWiFi`
179 - The `baseURL` host can be reached via a Wi-Fi connection.
180 -
181 - ### Keys for Notification UserInfo Dictionary
182 -
183 - Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
184 -
185 - `AFNetworkingReachabilityNotificationStatusItem`
186 - A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
187 - The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
188 - */
189 -
190 -///--------------------
191 -/// @name Notifications
192 -///--------------------
193 -
194 -/**
195 - Posted when network reachability changes.
196 - This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
197 -
198 - @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
199 - */
200 -FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
201 -FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
202 -
203 -///--------------------
204 -/// @name Functions
205 -///--------------------
206 -
207 -/**
208 - Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
209 - */
210 -FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
211 -
212 -NS_ASSUME_NONNULL_END
213 -#endif
1 -// AFNetworkReachabilityManager.m
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import "AFNetworkReachabilityManager.h"
23 -#if !TARGET_OS_WATCH
24 -
25 -#import <netinet/in.h>
26 -#import <netinet6/in6.h>
27 -#import <arpa/inet.h>
28 -#import <ifaddrs.h>
29 -#import <netdb.h>
30 -
31 -NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
32 -NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
33 -
34 -typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
35 -
36 -NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
37 - switch (status) {
38 - case AFNetworkReachabilityStatusNotReachable:
39 - return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
40 - case AFNetworkReachabilityStatusReachableViaWWAN:
41 - return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
42 - case AFNetworkReachabilityStatusReachableViaWiFi:
43 - return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
44 - case AFNetworkReachabilityStatusUnknown:
45 - default:
46 - return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
47 - }
48 -}
49 -
50 -static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
51 - BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
52 - BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
53 - BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
54 - BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
55 - BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
56 -
57 - AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
58 - if (isNetworkReachable == NO) {
59 - status = AFNetworkReachabilityStatusNotReachable;
60 - }
61 -#if TARGET_OS_IPHONE
62 - else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
63 - status = AFNetworkReachabilityStatusReachableViaWWAN;
64 - }
65 -#endif
66 - else {
67 - status = AFNetworkReachabilityStatusReachableViaWiFi;
68 - }
69 -
70 - return status;
71 -}
72 -
73 -/**
74 - * Queue a status change notification for the main thread.
75 - *
76 - * This is done to ensure that the notifications are received in the same order
77 - * as they are sent. If notifications are sent directly, it is possible that
78 - * a queued notification (for an earlier status condition) is processed after
79 - * the later update, resulting in the listener being left in the wrong state.
80 - */
81 -static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) {
82 - AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
83 - dispatch_async(dispatch_get_main_queue(), ^{
84 - if (block) {
85 - block(status);
86 - }
87 - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
88 - NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
89 - [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
90 - });
91 -}
92 -
93 -static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
94 - AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
95 -}
96 -
97 -
98 -static const void * AFNetworkReachabilityRetainCallback(const void *info) {
99 - return Block_copy(info);
100 -}
101 -
102 -static void AFNetworkReachabilityReleaseCallback(const void *info) {
103 - if (info) {
104 - Block_release(info);
105 - }
106 -}
107 -
108 -@interface AFNetworkReachabilityManager ()
109 -@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
110 -@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
111 -@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
112 -@end
113 -
114 -@implementation AFNetworkReachabilityManager
115 -
116 -+ (instancetype)sharedManager {
117 - static AFNetworkReachabilityManager *_sharedManager = nil;
118 - static dispatch_once_t onceToken;
119 - dispatch_once(&onceToken, ^{
120 - _sharedManager = [self manager];
121 - });
122 -
123 - return _sharedManager;
124 -}
125 -
126 -+ (instancetype)managerForDomain:(NSString *)domain {
127 - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
128 -
129 - AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
130 -
131 - CFRelease(reachability);
132 -
133 - return manager;
134 -}
135 -
136 -+ (instancetype)managerForAddress:(const void *)address {
137 - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
138 - AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
139 -
140 - CFRelease(reachability);
141 -
142 - return manager;
143 -}
144 -
145 -+ (instancetype)manager
146 -{
147 -#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
148 - struct sockaddr_in6 address;
149 - bzero(&address, sizeof(address));
150 - address.sin6_len = sizeof(address);
151 - address.sin6_family = AF_INET6;
152 -#else
153 - struct sockaddr_in address;
154 - bzero(&address, sizeof(address));
155 - address.sin_len = sizeof(address);
156 - address.sin_family = AF_INET;
157 -#endif
158 - return [self managerForAddress:&address];
159 -}
160 -
161 -- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
162 - self = [super init];
163 - if (!self) {
164 - return nil;
165 - }
166 -
167 - _networkReachability = CFRetain(reachability);
168 - self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
169 -
170 - return self;
171 -}
172 -
173 -- (instancetype)init NS_UNAVAILABLE
174 -{
175 - return nil;
176 -}
177 -
178 -- (void)dealloc {
179 - [self stopMonitoring];
180 -
181 - if (_networkReachability != NULL) {
182 - CFRelease(_networkReachability);
183 - }
184 -}
185 -
186 -#pragma mark -
187 -
188 -- (BOOL)isReachable {
189 - return [self isReachableViaWWAN] || [self isReachableViaWiFi];
190 -}
191 -
192 -- (BOOL)isReachableViaWWAN {
193 - return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
194 -}
195 -
196 -- (BOOL)isReachableViaWiFi {
197 - return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
198 -}
199 -
200 -#pragma mark -
201 -
202 -- (void)startMonitoring {
203 - [self stopMonitoring];
204 -
205 - if (!self.networkReachability) {
206 - return;
207 - }
208 -
209 - __weak __typeof(self)weakSelf = self;
210 - AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
211 - __strong __typeof(weakSelf)strongSelf = weakSelf;
212 -
213 - strongSelf.networkReachabilityStatus = status;
214 - if (strongSelf.networkReachabilityStatusBlock) {
215 - strongSelf.networkReachabilityStatusBlock(status);
216 - }
217 -
218 - };
219 -
220 - SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
221 - SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
222 - SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
223 -
224 - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
225 - SCNetworkReachabilityFlags flags;
226 - if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
227 - AFPostReachabilityStatusChange(flags, callback);
228 - }
229 - });
230 -}
231 -
232 -- (void)stopMonitoring {
233 - if (!self.networkReachability) {
234 - return;
235 - }
236 -
237 - SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
238 -}
239 -
240 -#pragma mark -
241 -
242 -- (NSString *)localizedNetworkReachabilityStatusString {
243 - return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
244 -}
245 -
246 -#pragma mark -
247 -
248 -- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
249 - self.networkReachabilityStatusBlock = block;
250 -}
251 -
252 -#pragma mark - NSKeyValueObserving
253 -
254 -+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
255 - if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
256 - return [NSSet setWithObject:@"networkReachabilityStatus"];
257 - }
258 -
259 - return [super keyPathsForValuesAffectingValueForKey:key];
260 -}
261 -
262 -@end
263 -#endif
1 -// AFNetworking.h
2 -//
3 -// Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 -//
5 -// Permission is hereby granted, free of charge, to any person obtaining a copy
6 -// of this software and associated documentation files (the "Software"), to deal
7 -// in the Software without restriction, including without limitation the rights
8 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -// copies of the Software, and to permit persons to whom the Software is
10 -// furnished to do so, subject to the following conditions:
11 -//
12 -// The above copyright notice and this permission notice shall be included in
13 -// all copies or substantial portions of the Software.
14 -//
15 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -// THE SOFTWARE.
22 -
23 -#import <Foundation/Foundation.h>
24 -#import <Availability.h>
25 -#import <TargetConditionals.h>
26 -
27 -#ifndef _AFNETWORKING_
28 - #define _AFNETWORKING_
29 -
30 - #import "AFURLRequestSerialization.h"
31 - #import "AFURLResponseSerialization.h"
32 - #import "AFSecurityPolicy.h"
33 -
34 -#if !TARGET_OS_WATCH
35 - #import "AFNetworkReachabilityManager.h"
36 -#endif
37 -
38 - #import "AFURLSessionManager.h"
39 - #import "AFHTTPSessionManager.h"
40 -
41 -#endif /* _AFNETWORKING_ */
1 -// AFSecurityPolicy.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <Foundation/Foundation.h>
23 -#import <Security/Security.h>
24 -
25 -typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
26 - AFSSLPinningModeNone,
27 - AFSSLPinningModePublicKey,
28 - AFSSLPinningModeCertificate,
29 -};
30 -
31 -/**
32 - `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
33 -
34 - Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
35 - */
36 -
37 -NS_ASSUME_NONNULL_BEGIN
38 -
39 -@interface AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
40 -
41 -/**
42 - The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
43 - */
44 -@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
45 -
46 -/**
47 - The certificates used to evaluate server trust according to the SSL pinning mode.
48 -
49 - By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
50 -
51 - Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
52 - */
53 -@property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
54 -
55 -/**
56 - Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
57 - */
58 -@property (nonatomic, assign) BOOL allowInvalidCertificates;
59 -
60 -/**
61 - Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
62 - */
63 -@property (nonatomic, assign) BOOL validatesDomainName;
64 -
65 -///-----------------------------------------
66 -/// @name Getting Certificates from the Bundle
67 -///-----------------------------------------
68 -
69 -/**
70 - Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
71 -
72 - @return The certificates included in the given bundle.
73 - */
74 -+ (NSSet <NSData *> *)certificatesInBundle:(NSBundle *)bundle;
75 -
76 -///-----------------------------------------
77 -/// @name Getting Specific Security Policies
78 -///-----------------------------------------
79 -
80 -/**
81 - Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
82 -
83 - @return The default security policy.
84 - */
85 -+ (instancetype)defaultPolicy;
86 -
87 -///---------------------
88 -/// @name Initialization
89 -///---------------------
90 -
91 -/**
92 - Creates and returns a security policy with the specified pinning mode.
93 -
94 - @param pinningMode The SSL pinning mode.
95 -
96 - @return A new security policy.
97 - */
98 -+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
99 -
100 -/**
101 - Creates and returns a security policy with the specified pinning mode.
102 -
103 - @param pinningMode The SSL pinning mode.
104 - @param pinnedCertificates The certificates to pin against.
105 -
106 - @return A new security policy.
107 - */
108 -+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
109 -
110 -///------------------------------
111 -/// @name Evaluating Server Trust
112 -///------------------------------
113 -
114 -/**
115 - Whether or not the specified server trust should be accepted, based on the security policy.
116 -
117 - This method should be used when responding to an authentication challenge from a server.
118 -
119 - @param serverTrust The X.509 certificate trust of the server.
120 - @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
121 -
122 - @return Whether or not to trust the server.
123 - */
124 -- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
125 - forDomain:(nullable NSString *)domain;
126 -
127 -@end
128 -
129 -NS_ASSUME_NONNULL_END
130 -
131 -///----------------
132 -/// @name Constants
133 -///----------------
134 -
135 -/**
136 - ## SSL Pinning Modes
137 -
138 - The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
139 -
140 - enum {
141 - AFSSLPinningModeNone,
142 - AFSSLPinningModePublicKey,
143 - AFSSLPinningModeCertificate,
144 - }
145 -
146 - `AFSSLPinningModeNone`
147 - Do not used pinned certificates to validate servers.
148 -
149 - `AFSSLPinningModePublicKey`
150 - Validate host certificates against public keys of pinned certificates.
151 -
152 - `AFSSLPinningModeCertificate`
153 - Validate host certificates against pinned certificates.
154 -*/
1 -// AFAutoPurgingImageCache.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <TargetConditionals.h>
23 -#import <Foundation/Foundation.h>
24 -
25 -#if TARGET_OS_IOS || TARGET_OS_TV
26 -#import <UIKit/UIKit.h>
27 -
28 -NS_ASSUME_NONNULL_BEGIN
29 -
30 -/**
31 - The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
32 - */
33 -@protocol AFImageCache <NSObject>
34 -
35 -/**
36 - Adds the image to the cache with the given identifier.
37 -
38 - @param image The image to cache.
39 - @param identifier The unique identifier for the image in the cache.
40 - */
41 -- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
42 -
43 -/**
44 - Removes the image from the cache matching the given identifier.
45 -
46 - @param identifier The unique identifier for the image in the cache.
47 -
48 - @return A BOOL indicating whether or not the image was removed from the cache.
49 - */
50 -- (BOOL)removeImageWithIdentifier:(NSString *)identifier;
51 -
52 -/**
53 - Removes all images from the cache.
54 -
55 - @return A BOOL indicating whether or not all images were removed from the cache.
56 - */
57 -- (BOOL)removeAllImages;
58 -
59 -/**
60 - Returns the image in the cache associated with the given identifier.
61 -
62 - @param identifier The unique identifier for the image in the cache.
63 -
64 - @return An image for the matching identifier, or nil.
65 - */
66 -- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
67 -@end
68 -
69 -
70 -/**
71 - The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier.
72 - */
73 -@protocol AFImageRequestCache <AFImageCache>
74 -
75 -/**
76 - Adds the image to the cache using an identifier created from the request and additional identifier.
77 -
78 - @param image The image to cache.
79 - @param request The unique URL request identifing the image asset.
80 - @param identifier The additional identifier to apply to the URL request to identify the image.
81 - */
82 -- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
83 -
84 -/**
85 - Removes the image from the cache using an identifier created from the request and additional identifier.
86 -
87 - @param request The unique URL request identifing the image asset.
88 - @param identifier The additional identifier to apply to the URL request to identify the image.
89 -
90 - @return A BOOL indicating whether or not all images were removed from the cache.
91 - */
92 -- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
93 -
94 -/**
95 - Returns the image from the cache associated with an identifier created from the request and additional identifier.
96 -
97 - @param request The unique URL request identifing the image asset.
98 - @param identifier The additional identifier to apply to the URL request to identify the image.
99 -
100 - @return An image for the matching request and identifier, or nil.
101 - */
102 -- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
103 -
104 -@end
105 -
106 -/**
107 - The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.
108 - */
109 -@interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache>
110 -
111 -/**
112 - The total memory capacity of the cache in bytes.
113 - */
114 -@property (nonatomic, assign) UInt64 memoryCapacity;
115 -
116 -/**
117 - The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
118 - */
119 -@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
120 -
121 -/**
122 - The current total memory usage in bytes of all images stored within the cache.
123 - */
124 -@property (nonatomic, assign, readonly) UInt64 memoryUsage;
125 -
126 -/**
127 - Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`.
128 -
129 - @return The new `AutoPurgingImageCache` instance.
130 - */
131 -- (instancetype)init;
132 -
133 -/**
134 - Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
135 - after purge limit.
136 -
137 - @param memoryCapacity The total memory capacity of the cache in bytes.
138 - @param preferredMemoryCapacity The preferred memory usage after purge in bytes.
139 -
140 - @return The new `AutoPurgingImageCache` instance.
141 - */
142 -- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
143 -
144 -@end
145 -
146 -NS_ASSUME_NONNULL_END
147 -
148 -#endif
149 -
1 -// AFAutoPurgingImageCache.m
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <TargetConditionals.h>
23 -
24 -#if TARGET_OS_IOS || TARGET_OS_TV
25 -
26 -#import "AFAutoPurgingImageCache.h"
27 -
28 -@interface AFCachedImage : NSObject
29 -
30 -@property (nonatomic, strong) UIImage *image;
31 -@property (nonatomic, strong) NSString *identifier;
32 -@property (nonatomic, assign) UInt64 totalBytes;
33 -@property (nonatomic, strong) NSDate *lastAccessDate;
34 -@property (nonatomic, assign) UInt64 currentMemoryUsage;
35 -
36 -@end
37 -
38 -@implementation AFCachedImage
39 -
40 --(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
41 - if (self = [self init]) {
42 - self.image = image;
43 - self.identifier = identifier;
44 -
45 - CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale);
46 - CGFloat bytesPerPixel = 4.0;
47 - CGFloat bytesPerSize = imageSize.width * imageSize.height;
48 - self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize;
49 - self.lastAccessDate = [NSDate date];
50 - }
51 - return self;
52 -}
53 -
54 -- (UIImage*)accessImage {
55 - self.lastAccessDate = [NSDate date];
56 - return self.image;
57 -}
58 -
59 -- (NSString *)description {
60 - NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate];
61 - return descriptionString;
62 -
63 -}
64 -
65 -@end
66 -
67 -@interface AFAutoPurgingImageCache ()
68 -@property (nonatomic, strong) NSMutableDictionary <NSString* , AFCachedImage*> *cachedImages;
69 -@property (nonatomic, assign) UInt64 currentMemoryUsage;
70 -@property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
71 -@end
72 -
73 -@implementation AFAutoPurgingImageCache
74 -
75 -- (instancetype)init {
76 - return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024];
77 -}
78 -
79 -- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity {
80 - if (self = [super init]) {
81 - self.memoryCapacity = memoryCapacity;
82 - self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity;
83 - self.cachedImages = [[NSMutableDictionary alloc] init];
84 -
85 - NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]];
86 - self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
87 -
88 - [[NSNotificationCenter defaultCenter]
89 - addObserver:self
90 - selector:@selector(removeAllImages)
91 - name:UIApplicationDidReceiveMemoryWarningNotification
92 - object:nil];
93 -
94 - }
95 - return self;
96 -}
97 -
98 -- (void)dealloc {
99 - [[NSNotificationCenter defaultCenter] removeObserver:self];
100 -}
101 -
102 -- (UInt64)memoryUsage {
103 - __block UInt64 result = 0;
104 - dispatch_sync(self.synchronizationQueue, ^{
105 - result = self.currentMemoryUsage;
106 - });
107 - return result;
108 -}
109 -
110 -- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
111 - dispatch_barrier_async(self.synchronizationQueue, ^{
112 - AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier];
113 -
114 - AFCachedImage *previousCachedImage = self.cachedImages[identifier];
115 - if (previousCachedImage != nil) {
116 - self.currentMemoryUsage -= previousCachedImage.totalBytes;
117 - }
118 -
119 - self.cachedImages[identifier] = cacheImage;
120 - self.currentMemoryUsage += cacheImage.totalBytes;
121 - });
122 -
123 - dispatch_barrier_async(self.synchronizationQueue, ^{
124 - if (self.currentMemoryUsage > self.memoryCapacity) {
125 - UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge;
126 - NSMutableArray <AFCachedImage*> *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues];
127 - NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate"
128 - ascending:YES];
129 - [sortedImages sortUsingDescriptors:@[sortDescriptor]];
130 -
131 - UInt64 bytesPurged = 0;
132 -
133 - for (AFCachedImage *cachedImage in sortedImages) {
134 - [self.cachedImages removeObjectForKey:cachedImage.identifier];
135 - bytesPurged += cachedImage.totalBytes;
136 - if (bytesPurged >= bytesToPurge) {
137 - break ;
138 - }
139 - }
140 - self.currentMemoryUsage -= bytesPurged;
141 - }
142 - });
143 -}
144 -
145 -- (BOOL)removeImageWithIdentifier:(NSString *)identifier {
146 - __block BOOL removed = NO;
147 - dispatch_barrier_sync(self.synchronizationQueue, ^{
148 - AFCachedImage *cachedImage = self.cachedImages[identifier];
149 - if (cachedImage != nil) {
150 - [self.cachedImages removeObjectForKey:identifier];
151 - self.currentMemoryUsage -= cachedImage.totalBytes;
152 - removed = YES;
153 - }
154 - });
155 - return removed;
156 -}
157 -
158 -- (BOOL)removeAllImages {
159 - __block BOOL removed = NO;
160 - dispatch_barrier_sync(self.synchronizationQueue, ^{
161 - if (self.cachedImages.count > 0) {
162 - [self.cachedImages removeAllObjects];
163 - self.currentMemoryUsage = 0;
164 - removed = YES;
165 - }
166 - });
167 - return removed;
168 -}
169 -
170 -- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier {
171 - __block UIImage *image = nil;
172 - dispatch_sync(self.synchronizationQueue, ^{
173 - AFCachedImage *cachedImage = self.cachedImages[identifier];
174 - image = [cachedImage accessImage];
175 - });
176 - return image;
177 -}
178 -
179 -- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
180 - [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
181 -}
182 -
183 -- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
184 - return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
185 -}
186 -
187 -- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
188 - return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
189 -}
190 -
191 -- (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier {
192 - NSString *key = request.URL.absoluteString;
193 - if (additionalIdentifier != nil) {
194 - key = [key stringByAppendingString:additionalIdentifier];
195 - }
196 - return key;
197 -}
198 -
199 -@end
200 -
201 -#endif
1 -// AFImageDownloader.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <TargetConditionals.h>
23 -
24 -#if TARGET_OS_IOS || TARGET_OS_TV
25 -
26 -#import <Foundation/Foundation.h>
27 -#import "AFAutoPurgingImageCache.h"
28 -#import "AFHTTPSessionManager.h"
29 -
30 -NS_ASSUME_NONNULL_BEGIN
31 -
32 -typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
33 - AFImageDownloadPrioritizationFIFO,
34 - AFImageDownloadPrioritizationLIFO
35 -};
36 -
37 -/**
38 - The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads.
39 - */
40 -@interface AFImageDownloadReceipt : NSObject
41 -
42 -/**
43 - The data task created by the `AFImageDownloader`.
44 -*/
45 -@property (nonatomic, strong) NSURLSessionDataTask *task;
46 -
47 -/**
48 - The unique identifier for the success and failure blocks when duplicate requests are made.
49 - */
50 -@property (nonatomic, strong) NSUUID *receiptID;
51 -@end
52 -
53 -/** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.
54 - */
55 -@interface AFImageDownloader : NSObject
56 -
57 -/**
58 - The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
59 - */
60 -@property (nonatomic, strong, nullable) id <AFImageRequestCache> imageCache;
61 -
62 -/**
63 - The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
64 - */
65 -@property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
66 -
67 -/**
68 - Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
69 - */
70 -@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton;
71 -
72 -/**
73 - The shared default instance of `AFImageDownloader` initialized with default values.
74 - */
75 -+ (instancetype)defaultInstance;
76 -
77 -/**
78 - Creates a default `NSURLCache` with common usage parameter values.
79 -
80 - @returns The default `NSURLCache` instance.
81 - */
82 -+ (NSURLCache *)defaultURLCache;
83 -
84 -/**
85 - Default initializer
86 -
87 - @return An instance of `AFImageDownloader` initialized with default values.
88 - */
89 -- (instancetype)init;
90 -
91 -/**
92 - Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
93 -
94 - @param sessionManager The session manager to use to download images.
95 - @param downloadPrioritization The download prioritization of the download queue.
96 - @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`.
97 - @param imageCache The image cache used to store all downloaded images in.
98 -
99 - @return The new `AFImageDownloader` instance.
100 - */
101 -- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
102 - downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
103 - maximumActiveDownloads:(NSInteger)maximumActiveDownloads
104 - imageCache:(nullable id <AFImageRequestCache>)imageCache;
105 -
106 -/**
107 - Creates a data task using the `sessionManager` instance for the specified URL request.
108 -
109 - If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
110 - appended to the already existing task. Once the task completes, all success or failure blocks attached to the
111 - task are executed in the order they were added.
112 -
113 - @param request The URL request.
114 - @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
115 - @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
116 -
117 - @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
118 - cache and the URL request cache policy allows the cache to be used.
119 - */
120 -- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
121 - success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
122 - failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
123 -
124 -/**
125 - Creates a data task using the `sessionManager` instance for the specified URL request.
126 -
127 - If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
128 - appended to the already existing task. Once the task completes, all success or failure blocks attached to the
129 - task are executed in the order they were added.
130 -
131 - @param request The URL request.
132 - @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request.
133 - @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
134 - @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
135 -
136 - @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
137 - cache and the URL request cache policy allows the cache to be used.
138 - */
139 -- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
140 - withReceiptID:(NSUUID *)receiptID
141 - success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
142 - failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
143 -
144 -/**
145 - Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
146 -
147 - If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.
148 -
149 - @param imageDownloadReceipt The image download receipt to cancel.
150 - */
151 -- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
152 -
153 -@end
154 -
155 -#endif
156 -
157 -NS_ASSUME_NONNULL_END
1 -// AFNetworkActivityIndicatorManager.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <Foundation/Foundation.h>
23 -
24 -#import <TargetConditionals.h>
25 -
26 -#if TARGET_OS_IOS
27 -
28 -#import <UIKit/UIKit.h>
29 -
30 -NS_ASSUME_NONNULL_BEGIN
31 -
32 -/**
33 - `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
34 -
35 - You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
36 -
37 - [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
38 -
39 - By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
40 -
41 - See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
42 - http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
43 - */
44 -NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
45 -@interface AFNetworkActivityIndicatorManager : NSObject
46 -
47 -/**
48 - A Boolean value indicating whether the manager is enabled.
49 -
50 - If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
51 - */
52 -@property (nonatomic, assign, getter = isEnabled) BOOL enabled;
53 -
54 -/**
55 - A Boolean value indicating whether the network activity indicator manager is currently active.
56 -*/
57 -@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
58 -
59 -/**
60 - A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds.
61 -
62 - Apple's HIG describes the following:
63 -
64 - > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence.
65 -
66 - */
67 -@property (nonatomic, assign) NSTimeInterval activationDelay;
68 -
69 -/**
70 - A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds.
71 - */
72 -
73 -@property (nonatomic, assign) NSTimeInterval completionDelay;
74 -
75 -/**
76 - Returns the shared network activity indicator manager object for the system.
77 -
78 - @return The systemwide network activity indicator manager.
79 - */
80 -+ (instancetype)sharedManager;
81 -
82 -/**
83 - Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
84 - */
85 -- (void)incrementActivityCount;
86 -
87 -/**
88 - Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
89 - */
90 -- (void)decrementActivityCount;
91 -
92 -/**
93 - Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward.
94 -
95 - @param block A block to be executed when the network activity indicator status changes.
96 - */
97 -- (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block;
98 -
99 -@end
100 -
101 -NS_ASSUME_NONNULL_END
102 -
103 -#endif
1 -// AFNetworkActivityIndicatorManager.m
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import "AFNetworkActivityIndicatorManager.h"
23 -
24 -#if TARGET_OS_IOS
25 -#import "AFURLSessionManager.h"
26 -
27 -typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) {
28 - AFNetworkActivityManagerStateNotActive,
29 - AFNetworkActivityManagerStateDelayingStart,
30 - AFNetworkActivityManagerStateActive,
31 - AFNetworkActivityManagerStateDelayingEnd
32 -};
33 -
34 -static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0;
35 -static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17;
36 -
37 -static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) {
38 - if ([[notification object] respondsToSelector:@selector(originalRequest)]) {
39 - return [(NSURLSessionTask *)[notification object] originalRequest];
40 - } else {
41 - return nil;
42 - }
43 -}
44 -
45 -typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible);
46 -
47 -@interface AFNetworkActivityIndicatorManager ()
48 -@property (readwrite, nonatomic, assign) NSInteger activityCount;
49 -@property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer;
50 -@property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer;
51 -@property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring;
52 -@property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock;
53 -@property (nonatomic, assign) AFNetworkActivityManagerState currentState;
54 -@property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
55 -
56 -- (void)updateCurrentStateForNetworkActivityChange;
57 -@end
58 -
59 -@implementation AFNetworkActivityIndicatorManager
60 -
61 -+ (instancetype)sharedManager {
62 - static AFNetworkActivityIndicatorManager *_sharedManager = nil;
63 - static dispatch_once_t oncePredicate;
64 - dispatch_once(&oncePredicate, ^{
65 - _sharedManager = [[self alloc] init];
66 - });
67 -
68 - return _sharedManager;
69 -}
70 -
71 -- (instancetype)init {
72 - self = [super init];
73 - if (!self) {
74 - return nil;
75 - }
76 - self.currentState = AFNetworkActivityManagerStateNotActive;
77 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil];
78 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil];
79 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil];
80 - self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay;
81 - self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay;
82 -
83 - return self;
84 -}
85 -
86 -- (void)dealloc {
87 - [[NSNotificationCenter defaultCenter] removeObserver:self];
88 -
89 - [_activationDelayTimer invalidate];
90 - [_completionDelayTimer invalidate];
91 -}
92 -
93 -- (void)setEnabled:(BOOL)enabled {
94 - _enabled = enabled;
95 - if (enabled == NO) {
96 - [self setCurrentState:AFNetworkActivityManagerStateNotActive];
97 - }
98 -}
99 -
100 -- (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block {
101 - self.networkActivityActionBlock = block;
102 -}
103 -
104 -- (BOOL)isNetworkActivityOccurring {
105 - @synchronized(self) {
106 - return self.activityCount > 0;
107 - }
108 -}
109 -
110 -- (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible {
111 - if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) {
112 - [self willChangeValueForKey:@"networkActivityIndicatorVisible"];
113 - @synchronized(self) {
114 - _networkActivityIndicatorVisible = networkActivityIndicatorVisible;
115 - }
116 - [self didChangeValueForKey:@"networkActivityIndicatorVisible"];
117 - if (self.networkActivityActionBlock) {
118 - self.networkActivityActionBlock(networkActivityIndicatorVisible);
119 - } else {
120 - [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible];
121 - }
122 - }
123 -}
124 -
125 -- (void)setActivityCount:(NSInteger)activityCount {
126 - @synchronized(self) {
127 - _activityCount = activityCount;
128 - }
129 -
130 - dispatch_async(dispatch_get_main_queue(), ^{
131 - [self updateCurrentStateForNetworkActivityChange];
132 - });
133 -}
134 -
135 -- (void)incrementActivityCount {
136 - [self willChangeValueForKey:@"activityCount"];
137 - @synchronized(self) {
138 - _activityCount++;
139 - }
140 - [self didChangeValueForKey:@"activityCount"];
141 -
142 - dispatch_async(dispatch_get_main_queue(), ^{
143 - [self updateCurrentStateForNetworkActivityChange];
144 - });
145 -}
146 -
147 -- (void)decrementActivityCount {
148 - [self willChangeValueForKey:@"activityCount"];
149 - @synchronized(self) {
150 - _activityCount = MAX(_activityCount - 1, 0);
151 - }
152 - [self didChangeValueForKey:@"activityCount"];
153 -
154 - dispatch_async(dispatch_get_main_queue(), ^{
155 - [self updateCurrentStateForNetworkActivityChange];
156 - });
157 -}
158 -
159 -- (void)networkRequestDidStart:(NSNotification *)notification {
160 - if ([AFNetworkRequestFromNotification(notification) URL]) {
161 - [self incrementActivityCount];
162 - }
163 -}
164 -
165 -- (void)networkRequestDidFinish:(NSNotification *)notification {
166 - if ([AFNetworkRequestFromNotification(notification) URL]) {
167 - [self decrementActivityCount];
168 - }
169 -}
170 -
171 -#pragma mark - Internal State Management
172 -- (void)setCurrentState:(AFNetworkActivityManagerState)currentState {
173 - @synchronized(self) {
174 - if (_currentState != currentState) {
175 - [self willChangeValueForKey:@"currentState"];
176 - _currentState = currentState;
177 - switch (currentState) {
178 - case AFNetworkActivityManagerStateNotActive:
179 - [self cancelActivationDelayTimer];
180 - [self cancelCompletionDelayTimer];
181 - [self setNetworkActivityIndicatorVisible:NO];
182 - break;
183 - case AFNetworkActivityManagerStateDelayingStart:
184 - [self startActivationDelayTimer];
185 - break;
186 - case AFNetworkActivityManagerStateActive:
187 - [self cancelCompletionDelayTimer];
188 - [self setNetworkActivityIndicatorVisible:YES];
189 - break;
190 - case AFNetworkActivityManagerStateDelayingEnd:
191 - [self startCompletionDelayTimer];
192 - break;
193 - }
194 - [self didChangeValueForKey:@"currentState"];
195 - }
196 -
197 - }
198 -}
199 -
200 -- (void)updateCurrentStateForNetworkActivityChange {
201 - if (self.enabled) {
202 - switch (self.currentState) {
203 - case AFNetworkActivityManagerStateNotActive:
204 - if (self.isNetworkActivityOccurring) {
205 - [self setCurrentState:AFNetworkActivityManagerStateDelayingStart];
206 - }
207 - break;
208 - case AFNetworkActivityManagerStateDelayingStart:
209 - //No op. Let the delay timer finish out.
210 - break;
211 - case AFNetworkActivityManagerStateActive:
212 - if (!self.isNetworkActivityOccurring) {
213 - [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd];
214 - }
215 - break;
216 - case AFNetworkActivityManagerStateDelayingEnd:
217 - if (self.isNetworkActivityOccurring) {
218 - [self setCurrentState:AFNetworkActivityManagerStateActive];
219 - }
220 - break;
221 - }
222 - }
223 -}
224 -
225 -- (void)startActivationDelayTimer {
226 - self.activationDelayTimer = [NSTimer
227 - timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO];
228 - [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes];
229 -}
230 -
231 -- (void)activationDelayTimerFired {
232 - if (self.networkActivityOccurring) {
233 - [self setCurrentState:AFNetworkActivityManagerStateActive];
234 - } else {
235 - [self setCurrentState:AFNetworkActivityManagerStateNotActive];
236 - }
237 -}
238 -
239 -- (void)startCompletionDelayTimer {
240 - [self.completionDelayTimer invalidate];
241 - self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO];
242 - [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes];
243 -}
244 -
245 -- (void)completionDelayTimerFired {
246 - [self setCurrentState:AFNetworkActivityManagerStateNotActive];
247 -}
248 -
249 -- (void)cancelActivationDelayTimer {
250 - [self.activationDelayTimer invalidate];
251 -}
252 -
253 -- (void)cancelCompletionDelayTimer {
254 - [self.completionDelayTimer invalidate];
255 -}
256 -
257 -@end
258 -
259 -#endif
1 -// UIActivityIndicatorView+AFNetworking.h
2 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 -//
4 -// Permission is hereby granted, free of charge, to any person obtaining a copy
5 -// of this software and associated documentation files (the "Software"), to deal
6 -// in the Software without restriction, including without limitation the rights
7 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -// copies of the Software, and to permit persons to whom the Software is
9 -// furnished to do so, subject to the following conditions:
10 -//
11 -// The above copyright notice and this permission notice shall be included in
12 -// all copies or substantial portions of the Software.
13 -//
14 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 -// THE SOFTWARE.
21 -
22 -#import <Foundation/Foundation.h>
23 -
24 -#import <TargetConditionals.h>
25 -
26 -#if TARGET_OS_IOS || TARGET_OS_TV
27 -
28 -#import <UIKit/UIKit.h>
29 -
30 -/**
31 - This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.
32 - */
33 -@interface UIActivityIndicatorView (AFNetworking)
34 -
35 -///----------------------------------
36 -/// @name Animating for Session Tasks
37 -///----------------------------------
38 -
39 -/**
40 - Binds the animating state to the state of the specified task.
41 -
42 - @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
43 - */
44 -- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
45 -
46 -@end
47 -
48 -#endif
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.