Vasilis

initial commit

Showing 184 changed files with 588 additions and 3459 deletions
No preview for this file type
No preview for this file type
No preview for this file type
1 +// Generated by Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
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 ObjectiveC;
192 +@import UIKit;
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 NSString;
211 +@class NSBundle;
212 +@class NSCoder;
213 +
214 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS7Coupons")
215 +@interface Coupons : UIViewController
216 +- (void)viewDidLoad;
217 +- (nonnull instancetype)initWithNibName:(NSString * _Nullable)nibNameOrNil bundle:(NSBundle * _Nullable)nibBundleOrNil OBJC_DESIGNATED_INITIALIZER;
218 +- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER;
219 +@end
220 +
221 +
222 +SWIFT_CLASS("_TtC21WarplySDKFrameworkIOS20CouponsViewInterface") SWIFT_AVAILABILITY(ios,introduced=13.0.0)
223 +@interface CouponsViewInterface : NSObject
224 ++ (UIViewController * _Nonnull)couponsViewController SWIFT_WARN_UNUSED_RESULT;
225 +- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
226 +@end
227 +
228 +
229 +#if __has_attribute(external_source_symbol)
230 +# pragma clang attribute pop
231 +#endif
232 +#pragma clang diagnostic pop
233 +#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 + DKCYcKMV6Mb8OA/NHHg7t6AGfa4=
10 + </data>
11 + <key>Coupons.nib</key>
12 + <data>
13 + U1ckDGrJNDxW08P7htkWHJqRgWQ=
14 + </data>
15 + <key>Headers/MyApi.h</key>
16 + <data>
17 + Ih/NyJXeSN/A2bEzkdwD1a9f9YE=
18 + </data>
19 + <key>Headers/WarplySDKFrameworkIOS-Swift.h</key>
20 + <data>
21 + kMf48Zhh1K3sIIsuYGLb9iSfvqI=
22 + </data>
23 + <key>Headers/WarplySDKFrameworkIOS.h</key>
24 + <data>
25 + K4p760R6wETJ3dCAo5mmJHRMOc8=
26 + </data>
27 + <key>Info.plist</key>
28 + <data>
29 + Z5Iptg21CUicJnZefwBkOkIYAWk=
30 + </data>
31 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
32 + <data>
33 + eBAN8llSLGmuQa6JgB+/bvCKocM=
34 + </data>
35 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64.swiftsourceinfo</key>
36 + <data>
37 + eBAN8llSLGmuQa6JgB+/bvCKocM=
38 + </data>
39 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftdoc</key>
40 + <data>
41 + DH+WJWLYtHZ/xyb7q1Cc9tqm2ls=
42 + </data>
43 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftmodule</key>
44 + <data>
45 + 1iExhjTxsAwtv5bNFdv65aWHdKg=
46 + </data>
47 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftdoc</key>
48 + <data>
49 + DH+WJWLYtHZ/xyb7q1Cc9tqm2ls=
50 + </data>
51 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftmodule</key>
52 + <data>
53 + 1iExhjTxsAwtv5bNFdv65aWHdKg=
54 + </data>
55 + <key>Modules/module.modulemap</key>
56 + <data>
57 + ha7ajEHIL6YE8KZ+4J/7MEDFDeQ=
58 + </data>
59 + <key>WLNativeAdCollectionViewCell.nib</key>
60 + <data>
61 + JpqcaqCHDLpEU0KqWMdaJnLZFLo=
62 + </data>
63 + <key>WLNativeAdTableViewCell.nib</key>
64 + <data>
65 + zZf6YWPmGYg525K3h6ctM+J67Gg=
66 + </data>
67 + <key>WLNativeVideoTableViewCell.nib</key>
68 + <data>
69 + QteeSEraaE/Rjil0rTcqFrUGRo0=
70 + </data>
71 + <key>ic_back.png</key>
72 + <data>
73 + WV/loTmJPkI/qJ62+ZvSx90zfuU=
74 + </data>
75 + <key>warp_white_back_button.png</key>
76 + <data>
77 + pv84pocjm3eAQq5wlCXc8R7ebyc=
78 + </data>
79 + <key>warp_white_back_button@2x.png</key>
80 + <data>
81 + oNR6mR20xRiKRlqAH/oO7bnXfbE=
82 + </data>
83 + <key>warp_white_close_button.png</key>
84 + <data>
85 + x2z+5O0GbOC4ZR5CRPg3vzjwU7g=
86 + </data>
87 + <key>warp_white_close_button@2x.png</key>
88 + <data>
89 + ZILm2ke1L8x4S6lKcRq4GJ+RoxY=
90 + </data>
91 + <key>warp_white_forward_button.png</key>
92 + <data>
93 + utaioQ40BK8eYPCmCZtfCkHfjxg=
94 + </data>
95 + <key>warp_white_forward_button@2x.png</key>
96 + <data>
97 + tH1io/Dscj0kbiukAcTCV3McTy0=
98 + </data>
99 + </dict>
100 + <key>files2</key>
101 + <dict>
102 + <key>Assets.car</key>
103 + <dict>
104 + <key>hash2</key>
105 + <data>
106 + Xac4exlC0Qp2HTrh0qL4NHqQVZn0lK/wrvzwWVvxpkg=
107 + </data>
108 + </dict>
109 + <key>Coupons.nib</key>
110 + <dict>
111 + <key>hash2</key>
112 + <data>
113 + mM03M76vk3gs0o89PfobwLZanZilelkwSEDNE2pEzcY=
114 + </data>
115 + </dict>
116 + <key>Headers/MyApi.h</key>
117 + <dict>
118 + <key>hash2</key>
119 + <data>
120 + hdN5KzzXrtLvcyOHg134rNHE8x34XtMbUcY2mzDQpu4=
121 + </data>
122 + </dict>
123 + <key>Headers/WarplySDKFrameworkIOS-Swift.h</key>
124 + <dict>
125 + <key>hash2</key>
126 + <data>
127 + x3esIbCN+RVwkzXNKlYy8Lt6rIP8LiKhby+jOtRQOZY=
128 + </data>
129 + </dict>
130 + <key>Headers/WarplySDKFrameworkIOS.h</key>
131 + <dict>
132 + <key>hash2</key>
133 + <data>
134 + vzJVcnjXgi6I7JknI81AWPBmBkpWBqV47pSppt4U80Q=
135 + </data>
136 + </dict>
137 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
138 + <dict>
139 + <key>hash2</key>
140 + <data>
141 + GPQr6kHtjp8lLYKTLaCsSHGi2GCpIVmefCU43pyy5Qo=
142 + </data>
143 + </dict>
144 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/Project/arm64.swiftsourceinfo</key>
145 + <dict>
146 + <key>hash2</key>
147 + <data>
148 + GPQr6kHtjp8lLYKTLaCsSHGi2GCpIVmefCU43pyy5Qo=
149 + </data>
150 + </dict>
151 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftdoc</key>
152 + <dict>
153 + <key>hash2</key>
154 + <data>
155 + mZE/2nBoABT5qbBx/4hgUK4MuSph0p64ImRGmwNCCDI=
156 + </data>
157 + </dict>
158 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64-apple-ios.swiftmodule</key>
159 + <dict>
160 + <key>hash2</key>
161 + <data>
162 + 9xR0dOGrYO6hv16x5tQ09ZJVk1DK7dnCOre72WlqNiw=
163 + </data>
164 + </dict>
165 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftdoc</key>
166 + <dict>
167 + <key>hash2</key>
168 + <data>
169 + mZE/2nBoABT5qbBx/4hgUK4MuSph0p64ImRGmwNCCDI=
170 + </data>
171 + </dict>
172 + <key>Modules/WarplySDKFrameworkIOS.swiftmodule/arm64.swiftmodule</key>
173 + <dict>
174 + <key>hash2</key>
175 + <data>
176 + 9xR0dOGrYO6hv16x5tQ09ZJVk1DK7dnCOre72WlqNiw=
177 + </data>
178 + </dict>
179 + <key>Modules/module.modulemap</key>
180 + <dict>
181 + <key>hash2</key>
182 + <data>
183 + WoUv3VxFCIOkz8D0t9OKGWoJvuudrgR/68KRVl1Yp6E=
184 + </data>
185 + </dict>
186 + <key>WLNativeAdCollectionViewCell.nib</key>
187 + <dict>
188 + <key>hash2</key>
189 + <data>
190 + 8zDmyYpy6RMFwd0JkLUlw7xzmtAZemgGKVmEzODdps4=
191 + </data>
192 + </dict>
193 + <key>WLNativeAdTableViewCell.nib</key>
194 + <dict>
195 + <key>hash2</key>
196 + <data>
197 + xtEvcJFiBXZcOI7/FHyU8BlACL5NoBjwKhXInWyZmf4=
198 + </data>
199 + </dict>
200 + <key>WLNativeVideoTableViewCell.nib</key>
201 + <dict>
202 + <key>hash2</key>
203 + <data>
204 + O1XoZW1GttwSIMwLp6MOHlGlfC1fFYbX4/FtVo47/H8=
205 + </data>
206 + </dict>
207 + <key>ic_back.png</key>
208 + <dict>
209 + <key>hash2</key>
210 + <data>
211 + KNgJyM13gK74GisuM8Zv7dqaymiHG/pNv2L1jncHk68=
212 + </data>
213 + </dict>
214 + <key>warp_white_back_button.png</key>
215 + <dict>
216 + <key>hash2</key>
217 + <data>
218 + WtLlGv8JSOkZku+rqKQw/tx/13nq8Qky49HihuGPap4=
219 + </data>
220 + </dict>
221 + <key>warp_white_back_button@2x.png</key>
222 + <dict>
223 + <key>hash2</key>
224 + <data>
225 + penUjNbdAPoMhsEppAckdM0XIU010PN+jLMPzJG4QRM=
226 + </data>
227 + </dict>
228 + <key>warp_white_close_button.png</key>
229 + <dict>
230 + <key>hash2</key>
231 + <data>
232 + X4A7Fpb03zzFpEdgF+ogLodSWFSO18v722IwMODWIYo=
233 + </data>
234 + </dict>
235 + <key>warp_white_close_button@2x.png</key>
236 + <dict>
237 + <key>hash2</key>
238 + <data>
239 + tNJ1aHwwf1aJWyA+odp5lRaBORb3sMSSVx245FPkGog=
240 + </data>
241 + </dict>
242 + <key>warp_white_forward_button.png</key>
243 + <dict>
244 + <key>hash2</key>
245 + <data>
246 + jrGN5n5MQ6X1nukL28B9bjP9y1MyYVkVI/ku12SFrVE=
247 + </data>
248 + </dict>
249 + <key>warp_white_forward_button@2x.png</key>
250 + <dict>
251 + <key>hash2</key>
252 + <data>
253 + 63yr7MF/rShpUW8P/RtOFP3ua9pbGuuD9cWAFIIutIs=
254 + </data>
255 + </dict>
256 + </dict>
257 + <key>rules</key>
258 + <dict>
259 + <key>^.*</key>
260 + <true/>
261 + <key>^.*\.lproj/</key>
262 + <dict>
263 + <key>optional</key>
264 + <true/>
265 + <key>weight</key>
266 + <real>1000</real>
267 + </dict>
268 + <key>^.*\.lproj/locversion.plist$</key>
269 + <dict>
270 + <key>omit</key>
271 + <true/>
272 + <key>weight</key>
273 + <real>1100</real>
274 + </dict>
275 + <key>^Base\.lproj/</key>
276 + <dict>
277 + <key>weight</key>
278 + <real>1010</real>
279 + </dict>
280 + <key>^version.plist$</key>
281 + <true/>
282 + </dict>
283 + <key>rules2</key>
284 + <dict>
285 + <key>.*\.dSYM($|/)</key>
286 + <dict>
287 + <key>weight</key>
288 + <real>11</real>
289 + </dict>
290 + <key>^(.*/)?\.DS_Store$</key>
291 + <dict>
292 + <key>omit</key>
293 + <true/>
294 + <key>weight</key>
295 + <real>2000</real>
296 + </dict>
297 + <key>^.*</key>
298 + <true/>
299 + <key>^.*\.lproj/</key>
300 + <dict>
301 + <key>optional</key>
302 + <true/>
303 + <key>weight</key>
304 + <real>1000</real>
305 + </dict>
306 + <key>^.*\.lproj/locversion.plist$</key>
307 + <dict>
308 + <key>omit</key>
309 + <true/>
310 + <key>weight</key>
311 + <real>1100</real>
312 + </dict>
313 + <key>^Base\.lproj/</key>
314 + <dict>
315 + <key>weight</key>
316 + <real>1010</real>
317 + </dict>
318 + <key>^Info\.plist$</key>
319 + <dict>
320 + <key>omit</key>
321 + <true/>
322 + <key>weight</key>
323 + <real>20</real>
324 + </dict>
325 + <key>^PkgInfo$</key>
326 + <dict>
327 + <key>omit</key>
328 + <true/>
329 + <key>weight</key>
330 + <real>20</real>
331 + </dict>
332 + <key>^embedded\.provisionprofile$</key>
333 + <dict>
334 + <key>weight</key>
335 + <real>20</real>
336 + </dict>
337 + <key>^version\.plist$</key>
338 + <dict>
339 + <key>weight</key>
340 + <real>20</real>
341 + </dict>
342 + </dict>
343 +</dict>
344 +</plist>
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" : "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" : "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" : "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 -# 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
1 -PODFILE CHECKSUM: 469e9ad6db6643e917950516ae5b80abb382aab0
2 -
3 -COCOAPODS: 1.11.2
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<Scheme
3 - LastUpgradeVersion = "1240"
4 - version = "1.3">
5 - <BuildAction
6 - parallelizeBuildables = "YES"
7 - buildImplicitDependencies = "YES">
8 - <BuildActionEntries>
9 - <BuildActionEntry
10 - buildForTesting = "YES"
11 - buildForRunning = "YES"
12 - buildForProfiling = "YES"
13 - buildForArchiving = "YES"
14 - buildForAnalyzing = "YES">
15 - <BuildableReference
16 - BuildableIdentifier = "primary"
17 - BlueprintIdentifier = "C6C64B3B320397CC1D8287CA8BA24255"
18 - BuildableName = "Pods_WarplySDKFrameworkIOS.framework"
19 - BlueprintName = "Pods-WarplySDKFrameworkIOS"
20 - ReferencedContainer = "container:Pods.xcodeproj">
21 - </BuildableReference>
22 - </BuildActionEntry>
23 - </BuildActionEntries>
24 - </BuildAction>
25 - <TestAction
26 - buildConfiguration = "Debug"
27 - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28 - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29 - shouldUseLaunchSchemeArgsEnv = "YES">
30 - <Testables>
31 - </Testables>
32 - </TestAction>
33 - <LaunchAction
34 - buildConfiguration = "Debug"
35 - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36 - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37 - launchStyle = "0"
38 - useCustomWorkingDirectory = "NO"
39 - ignoresPersistentStateOnLaunch = "NO"
40 - debugDocumentVersioning = "YES"
41 - debugServiceExtension = "internal"
42 - allowLocationSimulation = "YES">
43 - </LaunchAction>
44 - <ProfileAction
45 - buildConfiguration = "Release"
46 - shouldUseLaunchSchemeArgsEnv = "YES"
47 - savedToolIdentifier = ""
48 - useCustomWorkingDirectory = "NO"
49 - debugDocumentVersioning = "YES">
50 - </ProfileAction>
51 - <AnalyzeAction
52 - buildConfiguration = "Debug">
53 - </AnalyzeAction>
54 - <ArchiveAction
55 - buildConfiguration = "Release"
56 - revealArchiveInOrganizer = "YES">
57 - </ArchiveAction>
58 -</Scheme>
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>SchemeUserState</key>
6 - <dict>
7 - <key>Pods-WarplySDKFrameworkIOS.xcscheme</key>
8 - <dict>
9 - <key>isShown</key>
10 - <false/>
11 - <key>orderHint</key>
12 - <integer>0</integer>
13 - </dict>
14 - </dict>
15 - <key>SuppressBuildableAutocreation</key>
16 - <dict/>
17 -</dict>
18 -</plist>
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>CFBundleDevelopmentRegion</key>
6 - <string>en</string>
7 - <key>CFBundleExecutable</key>
8 - <string>${EXECUTABLE_NAME}</string>
9 - <key>CFBundleIdentifier</key>
10 - <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
11 - <key>CFBundleInfoDictionaryVersion</key>
12 - <string>6.0</string>
13 - <key>CFBundleName</key>
14 - <string>${PRODUCT_NAME}</string>
15 - <key>CFBundlePackageType</key>
16 - <string>FMWK</string>
17 - <key>CFBundleShortVersionString</key>
18 - <string>1.0.0</string>
19 - <key>CFBundleSignature</key>
20 - <string>????</string>
21 - <key>CFBundleVersion</key>
22 - <string>${CURRENT_PROJECT_VERSION}</string>
23 - <key>NSPrincipalClass</key>
24 - <string></string>
25 -</dict>
26 -</plist>
1 -# Acknowledgements
2 -This application makes use of the following third party libraries:
3 -Generated by CocoaPods - https://cocoapods.org
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>PreferenceSpecifiers</key>
6 - <array>
7 - <dict>
8 - <key>FooterText</key>
9 - <string>This application makes use of the following third party libraries:</string>
10 - <key>Title</key>
11 - <string>Acknowledgements</string>
12 - <key>Type</key>
13 - <string>PSGroupSpecifier</string>
14 - </dict>
15 - <dict>
16 - <key>FooterText</key>
17 - <string>Generated by CocoaPods - https://cocoapods.org</string>
18 - <key>Title</key>
19 - <string></string>
20 - <key>Type</key>
21 - <string>PSGroupSpecifier</string>
22 - </dict>
23 - </array>
24 - <key>StringsTable</key>
25 - <string>Acknowledgements</string>
26 - <key>Title</key>
27 - <string>Acknowledgements</string>
28 -</dict>
29 -</plist>
1 -#import <Foundation/Foundation.h>
2 -@interface PodsDummy_Pods_WarplySDKFrameworkIOS : NSObject
3 -@end
4 -@implementation PodsDummy_Pods_WarplySDKFrameworkIOS
5 -@end
1 -#ifdef __OBJC__
2 -#import <UIKit/UIKit.h>
3 -#else
4 -#ifndef FOUNDATION_EXPORT
5 -#if defined(__cplusplus)
6 -#define FOUNDATION_EXPORT extern "C"
7 -#else
8 -#define FOUNDATION_EXPORT extern
9 -#endif
10 -#endif
11 -#endif
12 -
13 -
14 -FOUNDATION_EXPORT double Pods_WarplySDKFrameworkIOSVersionNumber;
15 -FOUNDATION_EXPORT const unsigned char Pods_WarplySDKFrameworkIOSVersionString[];
16 -
1 -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 -PODS_BUILD_DIR = ${BUILD_DIR}
4 -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
5 -PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
6 -PODS_ROOT = ${SRCROOT}/Pods
7 -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
8 -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
1 -framework module Pods_WarplySDKFrameworkIOS {
2 - umbrella header "Pods-WarplySDKFrameworkIOS-umbrella.h"
3 -
4 - export *
5 - module * { export * }
6 -}
1 -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 -PODS_BUILD_DIR = ${BUILD_DIR}
4 -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
5 -PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
6 -PODS_ROOT = ${SRCROOT}/Pods
7 -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
8 -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
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
1 -// UIActivityIndicatorView+AFNetworking.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 "UIActivityIndicatorView+AFNetworking.h"
23 -#import <objc/runtime.h>
24 -
25 -#if TARGET_OS_IOS || TARGET_OS_TV
26 -
27 -#import "AFURLSessionManager.h"
28 -
29 -@interface AFActivityIndicatorViewNotificationObserver : NSObject
30 -@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
31 -- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView;
32 -
33 -- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
34 -
35 -@end
36 -
37 -@implementation UIActivityIndicatorView (AFNetworking)
38 -
39 -- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver {
40 - AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
41 - if (notificationObserver == nil) {
42 - notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self];
43 - objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 - }
45 - return notificationObserver;
46 -}
47 -
48 -- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
49 - [[self af_notificationObserver] setAnimatingWithStateOfTask:task];
50 -}
51 -
52 -@end
53 -
54 -@implementation AFActivityIndicatorViewNotificationObserver
55 -
56 -- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView
57 -{
58 - self = [super init];
59 - if (self) {
60 - _activityIndicatorView = activityIndicatorView;
61 - }
62 - return self;
63 -}
64 -
65 -- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
66 - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
67 -
68 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
69 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
70 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
71 -
72 - if (task) {
73 - if (task.state != NSURLSessionTaskStateCompleted) {
74 - UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView;
75 - if (task.state == NSURLSessionTaskStateRunning) {
76 - [activityIndicatorView startAnimating];
77 - } else {
78 - [activityIndicatorView stopAnimating];
79 - }
80 -
81 - [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
82 - [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
83 - [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
84 - }
85 - }
86 -}
87 -
88 -#pragma mark -
89 -
90 -- (void)af_startAnimating {
91 - dispatch_async(dispatch_get_main_queue(), ^{
92 - [self.activityIndicatorView startAnimating];
93 - });
94 -}
95 -
96 -- (void)af_stopAnimating {
97 - dispatch_async(dispatch_get_main_queue(), ^{
98 - [self.activityIndicatorView stopAnimating];
99 - });
100 -}
101 -
102 -#pragma mark -
103 -
104 -- (void)dealloc {
105 - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
106 -
107 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
108 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
109 - [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
110 -}
111 -
112 -@end
113 -
114 -#endif
1 -// UIButton+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 -NS_ASSUME_NONNULL_BEGIN
31 -
32 -@class AFImageDownloader;
33 -
34 -/**
35 - This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.
36 -
37 - @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
38 - */
39 -@interface UIButton (AFNetworking)
40 -
41 -///------------------------------------
42 -/// @name Accessing the Image Downloader
43 -///------------------------------------
44 -
45 -/**
46 - Set the shared image downloader used to download images.
47 -
48 - @param imageDownloader The shared image downloader used to download images.
49 -*/
50 -+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
51 -
52 -/**
53 - The shared image downloader used to download images.
54 - */
55 -+ (AFImageDownloader *)sharedImageDownloader;
56 -
57 -///--------------------
58 -/// @name Setting Image
59 -///--------------------
60 -
61 -/**
62 - Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
63 -
64 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
65 -
66 - @param state The control state.
67 - @param url The URL used for the image request.
68 - */
69 -- (void)setImageForState:(UIControlState)state
70 - withURL:(NSURL *)url;
71 -
72 -/**
73 - Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
74 -
75 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
76 -
77 - @param state The control state.
78 - @param url The URL used for the image request.
79 - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
80 - */
81 -- (void)setImageForState:(UIControlState)state
82 - withURL:(NSURL *)url
83 - placeholderImage:(nullable UIImage *)placeholderImage;
84 -
85 -/**
86 - Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
87 -
88 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
89 -
90 - If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
91 -
92 - @param state The control state.
93 - @param urlRequest The URL request used for the image request.
94 - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
95 - @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`.
96 - @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.
97 - */
98 -- (void)setImageForState:(UIControlState)state
99 - withURLRequest:(NSURLRequest *)urlRequest
100 - placeholderImage:(nullable UIImage *)placeholderImage
101 - success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
102 - failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
103 -
104 -
105 -///-------------------------------
106 -/// @name Setting Background Image
107 -///-------------------------------
108 -
109 -/**
110 - Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.
111 -
112 - If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.
113 -
114 - @param state The control state.
115 - @param url The URL used for the background image request.
116 - */
117 -- (void)setBackgroundImageForState:(UIControlState)state
118 - withURL:(NSURL *)url;
119 -
120 -/**
121 - Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
122 -
123 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
124 -
125 - @param state The control state.
126 - @param url The URL used for the background image request.
127 - @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
128 - */
129 -- (void)setBackgroundImageForState:(UIControlState)state
130 - withURL:(NSURL *)url
131 - placeholderImage:(nullable UIImage *)placeholderImage;
132 -
133 -/**
134 - Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
135 -
136 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
137 -
138 - If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied.
139 -
140 - @param state The control state.
141 - @param urlRequest The URL request used for the image request.
142 - @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
143 - @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`.
144 - @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.
145 - */
146 -- (void)setBackgroundImageForState:(UIControlState)state
147 - withURLRequest:(NSURLRequest *)urlRequest
148 - placeholderImage:(nullable UIImage *)placeholderImage
149 - success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
150 - failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
151 -
152 -
153 -///------------------------------
154 -/// @name Canceling Image Loading
155 -///------------------------------
156 -
157 -/**
158 - Cancels any executing image task for the specified control state of the receiver, if one exists.
159 -
160 - @param state The control state.
161 - */
162 -- (void)cancelImageDownloadTaskForState:(UIControlState)state;
163 -
164 -/**
165 - Cancels any executing background image task for the specified control state of the receiver, if one exists.
166 -
167 - @param state The control state.
168 - */
169 -- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state;
170 -
171 -@end
172 -
173 -NS_ASSUME_NONNULL_END
174 -
175 -#endif
1 -//
2 -// UIImage+AFNetworking.h
3 -//
4 -//
5 -// Created by Paulo Ferreira on 08/07/15.
6 -//
7 -// Permission is hereby granted, free of charge, to any person obtaining a copy
8 -// of this software and associated documentation files (the "Software"), to deal
9 -// in the Software without restriction, including without limitation the rights
10 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 -// copies of the Software, and to permit persons to whom the Software is
12 -// furnished to do so, subject to the following conditions:
13 -//
14 -// The above copyright notice and this permission notice shall be included in
15 -// all copies or substantial portions of the Software.
16 -//
17 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 -// THE SOFTWARE.
24 -
25 -#if TARGET_OS_IOS || TARGET_OS_TV
26 -
27 -#import <UIKit/UIKit.h>
28 -
29 -@interface UIImage (AFNetworking)
30 -
31 -+ (UIImage*) safeImageWithData:(NSData*)data;
32 -
33 -@end
34 -
35 -#endif
1 -// UIImageView+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 -NS_ASSUME_NONNULL_BEGIN
31 -
32 -@class AFImageDownloader;
33 -
34 -/**
35 - This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
36 - */
37 -@interface UIImageView (AFNetworking)
38 -
39 -///------------------------------------
40 -/// @name Accessing the Image Downloader
41 -///------------------------------------
42 -
43 -/**
44 - Set the shared image downloader used to download images.
45 -
46 - @param imageDownloader The shared image downloader used to download images.
47 - */
48 -+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
49 -
50 -/**
51 - The shared image downloader used to download images.
52 - */
53 -+ (AFImageDownloader *)sharedImageDownloader;
54 -
55 -///--------------------
56 -/// @name Setting Image
57 -///--------------------
58 -
59 -/**
60 - Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
61 -
62 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
63 -
64 - By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
65 -
66 - @param url The URL used for the image request.
67 - */
68 -- (void)setImageWithURL:(NSURL *)url;
69 -
70 -/**
71 - Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
72 -
73 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
74 -
75 - By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
76 -
77 - @param url The URL used for the image request.
78 - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
79 - */
80 -- (void)setImageWithURL:(NSURL *)url
81 - placeholderImage:(nullable UIImage *)placeholderImage;
82 -
83 -/**
84 - Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
85 -
86 - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
87 -
88 - If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
89 -
90 - @param urlRequest The URL request used for the image request.
91 - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
92 - @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`.
93 - @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.
94 - */
95 -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
96 - placeholderImage:(nullable UIImage *)placeholderImage
97 - success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
98 - failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
99 -
100 -/**
101 - Cancels any executing image operation for the receiver, if one exists.
102 - */
103 -- (void)cancelImageDownloadTask;
104 -
105 -@end
106 -
107 -NS_ASSUME_NONNULL_END
108 -
109 -#endif
1 -// UIImageView+AFNetworking.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 "UIImageView+AFNetworking.h"
23 -
24 -#import <objc/runtime.h>
25 -
26 -#if TARGET_OS_IOS || TARGET_OS_TV
27 -
28 -#import "AFImageDownloader.h"
29 -
30 -@interface UIImageView (_AFNetworking)
31 -@property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt;
32 -@end
33 -
34 -@implementation UIImageView (_AFNetworking)
35 -
36 -- (AFImageDownloadReceipt *)af_activeImageDownloadReceipt {
37 - return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt));
38 -}
39 -
40 -- (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
41 - objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
42 -}
43 -
44 -@end
45 -
46 -#pragma mark -
47 -
48 -@implementation UIImageView (AFNetworking)
49 -
50 -+ (AFImageDownloader *)sharedImageDownloader {
51 - return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
52 -}
53 -
54 -+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
55 - objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
56 -}
57 -
58 -#pragma mark -
59 -
60 -- (void)setImageWithURL:(NSURL *)url {
61 - [self setImageWithURL:url placeholderImage:nil];
62 -}
63 -
64 -- (void)setImageWithURL:(NSURL *)url
65 - placeholderImage:(UIImage *)placeholderImage
66 -{
67 - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
68 - [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
69 -
70 - [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
71 -}
72 -
73 -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
74 - placeholderImage:(UIImage *)placeholderImage
75 - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
76 - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
77 -{
78 -
79 - if ([urlRequest URL] == nil) {
80 - [self cancelImageDownloadTask];
81 - self.image = placeholderImage;
82 - return;
83 - }
84 -
85 - if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
86 - return;
87 - }
88 -
89 - [self cancelImageDownloadTask];
90 -
91 - AFImageDownloader *downloader = [[self class] sharedImageDownloader];
92 - id <AFImageRequestCache> imageCache = downloader.imageCache;
93 -
94 - //Use the image from the image cache if it exists
95 - UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
96 - if (cachedImage) {
97 - if (success) {
98 - success(urlRequest, nil, cachedImage);
99 - } else {
100 - self.image = cachedImage;
101 - }
102 - [self clearActiveDownloadInformation];
103 - } else {
104 - if (placeholderImage) {
105 - self.image = placeholderImage;
106 - }
107 -
108 - __weak __typeof(self)weakSelf = self;
109 - NSUUID *downloadID = [NSUUID UUID];
110 - AFImageDownloadReceipt *receipt;
111 - receipt = [downloader
112 - downloadImageForURLRequest:urlRequest
113 - withReceiptID:downloadID
114 - success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
115 - __strong __typeof(weakSelf)strongSelf = weakSelf;
116 - if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
117 - if (success) {
118 - success(request, response, responseObject);
119 - } else if(responseObject) {
120 - strongSelf.image = responseObject;
121 - }
122 - [strongSelf clearActiveDownloadInformation];
123 - }
124 -
125 - }
126 - failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
127 - __strong __typeof(weakSelf)strongSelf = weakSelf;
128 - if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
129 - if (failure) {
130 - failure(request, response, error);
131 - }
132 - [strongSelf clearActiveDownloadInformation];
133 - }
134 - }];
135 -
136 - self.af_activeImageDownloadReceipt = receipt;
137 - }
138 -}
139 -
140 -- (void)cancelImageDownloadTask {
141 - if (self.af_activeImageDownloadReceipt != nil) {
142 - [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt];
143 - [self clearActiveDownloadInformation];
144 - }
145 -}
146 -
147 -- (void)clearActiveDownloadInformation {
148 - self.af_activeImageDownloadReceipt = nil;
149 -}
150 -
151 -- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest {
152 - return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
153 -}
154 -
155 -@end
156 -
157 -#endif
1 -// UIKit+AFNetworking.h
2 -//
3 -// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 -#if TARGET_OS_IOS || TARGET_OS_TV
24 -#import <UIKit/UIKit.h>
25 -
26 -#ifndef _UIKIT_AFNETWORKING_
27 - #define _UIKIT_AFNETWORKING_
28 -
29 -#if TARGET_OS_IOS
30 - #import "AFAutoPurgingImageCache.h"
31 - #import "AFImageDownloader.h"
32 - #import "AFNetworkActivityIndicatorManager.h"
33 - #import "UIRefreshControl+AFNetworking.h"
34 - #import "UIWebView+AFNetworking.h"
35 -#endif
36 -
37 - #import "UIActivityIndicatorView+AFNetworking.h"
38 - #import "UIButton+AFNetworking.h"
39 - #import "UIImageView+AFNetworking.h"
40 - #import "UIProgressView+AFNetworking.h"
41 -#endif /* _UIKIT_AFNETWORKING_ */
42 -#endif
1 -// UIProgressView+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 -NS_ASSUME_NONNULL_BEGIN
31 -
32 -
33 -/**
34 - This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task.
35 - */
36 -@interface UIProgressView (AFNetworking)
37 -
38 -///------------------------------------
39 -/// @name Setting Session Task Progress
40 -///------------------------------------
41 -
42 -/**
43 - Binds the progress to the upload progress of the specified session task.
44 -
45 - @param task The session task.
46 - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
47 - */
48 -- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
49 - animated:(BOOL)animated;
50 -
51 -/**
52 - Binds the progress to the download progress of the specified session task.
53 -
54 - @param task The session task.
55 - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
56 - */
57 -- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
58 - animated:(BOOL)animated;
59 -
60 -@end
61 -
62 -NS_ASSUME_NONNULL_END
63 -
64 -#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.
This diff is collapsed. Click to expand it.