├── Podfile ├── Podfile.lock ├── Pods ├── Headers │ └── Private │ │ └── MBProgressHUD │ │ └── MBProgressHUD.h ├── MBProgressHUD │ ├── LICENSE │ ├── MBProgressHUD.h │ ├── MBProgressHUD.m │ └── README.mdown ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── Chintan.xcuserdatad │ │ └── xcschemes │ │ ├── MBProgressHUD.xcscheme │ │ ├── Pods-iOS Alexa.xcscheme │ │ └── xcschememanagement.plist └── Target Support Files │ ├── MBProgressHUD │ ├── Info.plist │ ├── MBProgressHUD-dummy.m │ ├── MBProgressHUD-prefix.pch │ ├── MBProgressHUD-umbrella.h │ ├── MBProgressHUD.modulemap │ └── MBProgressHUD.xcconfig │ └── Pods-iOS Alexa │ ├── Info.plist │ ├── Pods-iOS Alexa-acknowledgements.markdown │ ├── Pods-iOS Alexa-acknowledgements.plist │ ├── Pods-iOS Alexa-dummy.m │ ├── Pods-iOS Alexa-frameworks.sh │ ├── Pods-iOS Alexa-resources.sh │ ├── Pods-iOS Alexa-umbrella.h │ ├── Pods-iOS Alexa.debug.xcconfig │ ├── Pods-iOS Alexa.modulemap │ └── Pods-iOS Alexa.release.xcconfig ├── README.md ├── iOS Alexa.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── Chintan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Chintan.xcuserdatad │ └── xcschemes │ ├── iOS Alexa.xcscheme │ └── xcschememanagement.plist ├── iOS Alexa.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── Chintan.xcuserdatad │ └── UserInterfaceState.xcuserstate └── iOS Alexa ├── AVS ├── AVSUploader.swift ├── Config.swift └── SimplePCMRecorder.swift ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json ├── Contents.json ├── LoginButtonIcon.imageset │ ├── Contents.json │ └── btnLWA_gold_314x72.png ├── MicIcon.imageset │ ├── 1463769285_microphone.png │ └── Contents.json └── StopIcon.imageset │ ├── Contents.json │ └── Untitled11111.png ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── ISSharedData.swift ├── Info.plist ├── LoginWithAmazon.framework ├── Headers │ ├── AIAuthenticationDelegate.h │ ├── AIError.h │ ├── AIMobileLib.h │ └── LoginWithAmazon.h ├── LoginWithAmazon └── Versions │ ├── A │ ├── Headers │ │ ├── AIAuthenticationDelegate.h │ │ ├── AIError.h │ │ ├── AIMobileLib.h │ │ └── LoginWithAmazon.h │ └── LoginWithAmazon │ └── Current │ ├── Headers │ ├── AIAuthenticationDelegate.h │ ├── AIError.h │ ├── AIMobileLib.h │ └── LoginWithAmazon.h │ └── LoginWithAmazon ├── ViewController ├── HomeViewController.swift ├── LoginViewController.h └── LoginViewController.m └── iOS Alexa-Bridging-Header.h /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '8.0' 3 | # Uncomment this line if you're using Swift 4 | use_frameworks! 5 | 6 | target 'iOS Alexa’ do 7 | pod 'MBProgressHUD' 8 | end 9 | 10 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - MBProgressHUD 6 | 7 | SPEC CHECKSUMS: 8 | MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a 9 | 10 | COCOAPODS: 0.39.0 11 | -------------------------------------------------------------------------------- /Pods/Headers/Private/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | ../../../MBProgressHUD/MBProgressHUD.h -------------------------------------------------------------------------------- /Pods/MBProgressHUD/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2009-2016 Matej Bukovinski 2 | 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 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Pods/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.h 3 | // Version 1.0.0 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | // This code is distributed under the terms and conditions of the MIT license. 8 | 9 | // Copyright © 2009-2016 Matej Bukovinski 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | #import 30 | #import 31 | #import 32 | 33 | @class MBBackgroundView; 34 | @protocol MBProgressHUDDelegate; 35 | 36 | 37 | extern CGFloat const MBProgressMaxOffset; 38 | 39 | typedef NS_ENUM(NSInteger, MBProgressHUDMode) { 40 | /// UIActivityIndicatorView. 41 | MBProgressHUDModeIndeterminate, 42 | /// A round, pie-chart like, progress view. 43 | MBProgressHUDModeDeterminate, 44 | /// Horizontal progress bar. 45 | MBProgressHUDModeDeterminateHorizontalBar, 46 | /// Ring-shaped progress view. 47 | MBProgressHUDModeAnnularDeterminate, 48 | /// Shows a custom view. 49 | MBProgressHUDModeCustomView, 50 | /// Shows only labels. 51 | MBProgressHUDModeText 52 | }; 53 | 54 | typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) { 55 | /// Opacity animation 56 | MBProgressHUDAnimationFade, 57 | /// Opacity + scale animation (zoom in when appearing zoom out when disappearing) 58 | MBProgressHUDAnimationZoom, 59 | /// Opacity + scale animation (zoom out style) 60 | MBProgressHUDAnimationZoomOut, 61 | /// Opacity + scale animation (zoom in style) 62 | MBProgressHUDAnimationZoomIn 63 | }; 64 | 65 | typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) { 66 | /// Solid color background 67 | MBProgressHUDBackgroundStyleSolidColor, 68 | /// UIVisualEffectView or UIToolbar.layer background view 69 | MBProgressHUDBackgroundStyleBlur 70 | }; 71 | 72 | typedef void (^MBProgressHUDCompletionBlock)(); 73 | 74 | 75 | NS_ASSUME_NONNULL_BEGIN 76 | 77 | 78 | /** 79 | * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. 80 | * 81 | * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. 82 | * The MBProgressHUD window spans over the entire space given to it by the initWithFrame: constructor and catches all 83 | * user input on this region, thereby preventing the user operations on components below the view. 84 | * 85 | * @note To still allow touches to pass through the HUD, you can set hud.userInteractionEnabled = NO. 86 | * @attention MBProgressHUD is a UI class and should therefore only be accessed on the main thread. 87 | */ 88 | @interface MBProgressHUD : UIView 89 | 90 | /** 91 | * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. 92 | * 93 | * @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden. 94 | * 95 | * @param view The view that the HUD will be added to 96 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 97 | * animations while appearing. 98 | * @return A reference to the created HUD. 99 | * 100 | * @see hideHUDForView:animated: 101 | * @see animationType 102 | */ 103 | + (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; 104 | 105 | /// @name Showing and hiding 106 | 107 | /** 108 | * Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:. 109 | * 110 | * @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden. 111 | * 112 | * @param view The view that is going to be searched for a HUD subview. 113 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 114 | * animations while disappearing. 115 | * @return YES if a HUD was found and removed, NO otherwise. 116 | * 117 | * @see showHUDAddedTo:animated: 118 | * @see animationType 119 | */ 120 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; 121 | 122 | /** 123 | * Finds the top-most HUD subview and returns it. 124 | * 125 | * @param view The view that is going to be searched. 126 | * @return A reference to the last HUD subview discovered. 127 | */ 128 | + (nullable MBProgressHUD *)HUDForView:(UIView *)view; 129 | 130 | /** 131 | * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with 132 | * view.bounds as the parameter. 133 | * 134 | * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as 135 | * the HUD's superview (i.e., the view that the HUD will be added to). 136 | */ 137 | - (instancetype)initWithView:(UIView *)view; 138 | 139 | /** 140 | * Displays the HUD. 141 | * 142 | * @note You need to make sure that the main thread completes its run loop soon after this method call so that 143 | * the user interface can be updated. Call this method when your task is already set up to be executed in a new thread 144 | * (e.g., when using something like NSOperation or making an asynchronous call like NSURLRequest). 145 | * 146 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 147 | * animations while appearing. 148 | * 149 | * @see animationType 150 | */ 151 | - (void)showAnimated:(BOOL)animated; 152 | 153 | /** 154 | * Hides the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 155 | * hide the HUD when your task completes. 156 | * 157 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 158 | * animations while disappearing. 159 | * 160 | * @see animationType 161 | */ 162 | - (void)hideAnimated:(BOOL)animated; 163 | 164 | /** 165 | * Hides the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 166 | * hide the HUD when your task completes. 167 | * 168 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 169 | * animations while disappearing. 170 | * @param delay Delay in seconds until the HUD is hidden. 171 | * 172 | * @see animationType 173 | */ 174 | - (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay; 175 | 176 | /** 177 | * The HUD delegate object. Receives HUD state notifications. 178 | */ 179 | @property (weak, nonatomic) id delegate; 180 | 181 | /** 182 | * Called after the HUD is hiden. 183 | */ 184 | @property (copy, nullable) MBProgressHUDCompletionBlock completionBlock; 185 | 186 | /* 187 | * Grace period is the time (in seconds) that the invoked method may be run without 188 | * showing the HUD. If the task finishes before the grace time runs out, the HUD will 189 | * not be shown at all. 190 | * This may be used to prevent HUD display for very short tasks. 191 | * Defaults to 0 (no grace time). 192 | */ 193 | @property (assign, nonatomic) NSTimeInterval graceTime; 194 | 195 | /** 196 | * The minimum time (in seconds) that the HUD is shown. 197 | * This avoids the problem of the HUD being shown and than instantly hidden. 198 | * Defaults to 0 (no minimum show time). 199 | */ 200 | @property (assign, nonatomic) NSTimeInterval minShowTime; 201 | 202 | /** 203 | * Removes the HUD from its parent view when hidden. 204 | * Defaults to NO. 205 | */ 206 | @property (assign, nonatomic) BOOL removeFromSuperViewOnHide; 207 | 208 | /// @name Appearance 209 | 210 | /** 211 | * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. 212 | */ 213 | @property (assign, nonatomic) MBProgressHUDMode mode; 214 | 215 | /** 216 | * A color that gets forwarded to all labels and supported indicators. Also sets the tintColor 217 | * for custom views on iOS 7+. Set to nil to manage color individually. 218 | * Defaults to semi-translucent black on iOS 7 and later and white on earlier iOS versions. 219 | */ 220 | @property (strong, nonatomic, nullable) UIColor *contentColor UI_APPEARANCE_SELECTOR; 221 | 222 | /** 223 | * The animation type that should be used when the HUD is shown and hidden. 224 | */ 225 | @property (assign, nonatomic) MBProgressHUDAnimation animationType UI_APPEARANCE_SELECTOR; 226 | 227 | /** 228 | * The bezel offset relative to the center of the view. You can use MBProgressMaxOffset 229 | * and -MBProgressMaxOffset to move the HUD all the way to the screen edge in each direction. 230 | * E.g., CGPointMake(0.f, MBProgressMaxOffset) would position the HUD centered on the bottom edge. 231 | */ 232 | @property (assign, nonatomic) CGPoint offset UI_APPEARANCE_SELECTOR; 233 | 234 | /** 235 | * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). 236 | * This also represents the minimum bezel distance to the edge of the HUD view. 237 | * Defaults to 20.f 238 | */ 239 | @property (assign, nonatomic) CGFloat margin UI_APPEARANCE_SELECTOR; 240 | 241 | /** 242 | * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). 243 | */ 244 | @property (assign, nonatomic) CGSize minSize UI_APPEARANCE_SELECTOR; 245 | 246 | /** 247 | * Force the HUD dimensions to be equal if possible. 248 | */ 249 | @property (assign, nonatomic, getter = isSquare) BOOL square UI_APPEARANCE_SELECTOR; 250 | 251 | /** 252 | * When enabled, the bezel center gets slightly affected by the device accelerometer data. 253 | * Has no effect on iOS < 7.0. Defaults to YES. 254 | */ 255 | @property (assign, nonatomic, getter=areDefaultMotionEffectsEnabled) BOOL defaultMotionEffectsEnabled UI_APPEARANCE_SELECTOR; 256 | 257 | /// @name Progress 258 | 259 | /** 260 | * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. 261 | */ 262 | @property (assign, nonatomic) float progress; 263 | 264 | /// @name ProgressObject 265 | 266 | /** 267 | * The NSProgress object feeding the progress information to the progress indicator. 268 | */ 269 | @property (strong, nonatomic, nullable) NSProgress *progressObject; 270 | 271 | /// @name Views 272 | 273 | /** 274 | * The view containing the labels and indicator (or customView). 275 | */ 276 | @property (strong, nonatomic, readonly) MBBackgroundView *bezelView; 277 | 278 | /** 279 | * View covering the entire HUD area, placed behind bezelView. 280 | */ 281 | @property (strong, nonatomic, readonly) MBBackgroundView *backgroundView; 282 | 283 | /** 284 | * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. 285 | * The view should implement intrinsicContentSize for proper sizing. For best results use approximately 37 by 37 pixels. 286 | */ 287 | @property (strong, nonatomic, nullable) UIView *customView; 288 | 289 | /** 290 | * A label that holds an optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit 291 | * the entire text. 292 | */ 293 | @property (strong, nonatomic, readonly) UILabel *label; 294 | 295 | /** 296 | * A label that holds an optional details message displayed below the labelText message. The details text can span multiple lines. 297 | */ 298 | @property (strong, nonatomic, readonly) UILabel *detailsLabel; 299 | 300 | /** 301 | * A button that is placed below the labels. Visible only if a target / action is added. 302 | */ 303 | @property (strong, nonatomic, readonly) UIButton *button; 304 | 305 | @end 306 | 307 | 308 | @protocol MBProgressHUDDelegate 309 | 310 | @optional 311 | 312 | /** 313 | * Called after the HUD was fully hidden from the screen. 314 | */ 315 | - (void)hudWasHidden:(MBProgressHUD *)hud; 316 | 317 | @end 318 | 319 | 320 | /** 321 | * A progress view for showing definite progress by filling up a circle (pie chart). 322 | */ 323 | @interface MBRoundProgressView : UIView 324 | 325 | /** 326 | * Progress (0.0 to 1.0) 327 | */ 328 | @property (nonatomic, assign) float progress; 329 | 330 | /** 331 | * Indicator progress color. 332 | * Defaults to white [UIColor whiteColor]. 333 | */ 334 | @property (nonatomic, strong) UIColor *progressTintColor; 335 | 336 | /** 337 | * Indicator background (non-progress) color. 338 | * Only applicable on iOS versions older than iOS 7. 339 | * Defaults to translucent white (alpha 0.1). 340 | */ 341 | @property (nonatomic, strong) UIColor *backgroundTintColor; 342 | 343 | /* 344 | * Display mode - NO = round or YES = annular. Defaults to round. 345 | */ 346 | @property (nonatomic, assign, getter = isAnnular) BOOL annular; 347 | 348 | @end 349 | 350 | 351 | /** 352 | * A flat bar progress view. 353 | */ 354 | @interface MBBarProgressView : UIView 355 | 356 | /** 357 | * Progress (0.0 to 1.0) 358 | */ 359 | @property (nonatomic, assign) float progress; 360 | 361 | /** 362 | * Bar border line color. 363 | * Defaults to white [UIColor whiteColor]. 364 | */ 365 | @property (nonatomic, strong) UIColor *lineColor; 366 | 367 | /** 368 | * Bar background color. 369 | * Defaults to clear [UIColor clearColor]; 370 | */ 371 | @property (nonatomic, strong) UIColor *progressRemainingColor; 372 | 373 | /** 374 | * Bar progress color. 375 | * Defaults to white [UIColor whiteColor]. 376 | */ 377 | @property (nonatomic, strong) UIColor *progressColor; 378 | 379 | @end 380 | 381 | 382 | @interface MBBackgroundView : UIView 383 | 384 | /** 385 | * The background style. 386 | * Defaults to MBProgressHUDBackgroundStyleBlur on iOS 7 or later and MBProgressHUDBackgroundStyleSolidColor otherwise. 387 | * @note Due to iOS 7 not supporting UIVisualEffectView, the blur effect differs slightly between iOS 7 and later versions. 388 | */ 389 | @property (nonatomic) MBProgressHUDBackgroundStyle style; 390 | 391 | /** 392 | * The background color or the blur tint color. 393 | * @note Due to iOS 7 not supporting UIVisualEffectView, the blur effect differs slightly between iOS 7 and later versions. 394 | */ 395 | @property (nonatomic, strong) UIColor *color; 396 | 397 | @end 398 | 399 | @interface MBProgressHUD (Deprecated) 400 | 401 | + (NSArray *)allHUDsForView:(UIView *)view __attribute__((deprecated("Store references when using more than one HUD per view."))); 402 | + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated __attribute__((deprecated("Store references when using more than one HUD per view."))); 403 | 404 | - (id)initWithWindow:(UIWindow *)window __attribute__((deprecated("Use initWithView: instead."))); 405 | 406 | - (void)show:(BOOL)animated __attribute__((deprecated("Use showAnimated: instead."))); 407 | - (void)hide:(BOOL)animated __attribute__((deprecated("Use hideAnimated: instead."))); 408 | - (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay __attribute__((deprecated("Use hideAnimated:afterDelay: instead."))); 409 | 410 | - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated __attribute__((deprecated("Use GCD directly."))); 411 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block __attribute__((deprecated("Use GCD directly."))); 412 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly."))); 413 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue __attribute__((deprecated("Use GCD directly."))); 414 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue 415 | completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly."))); 416 | @property (assign) BOOL taskInProgress __attribute__((deprecated("No longer needed."))); 417 | 418 | @property (nonatomic, copy) NSString *labelText __attribute__((deprecated("Use label.text instead."))); 419 | @property (nonatomic, strong) UIFont *labelFont __attribute__((deprecated("Use label.font instead."))); 420 | @property (nonatomic, strong) UIColor *labelColor __attribute__((deprecated("Use label.textColor instead."))); 421 | @property (nonatomic, copy) NSString *detailsLabelText __attribute__((deprecated("Use detailsLabel.text instead."))); 422 | @property (nonatomic, strong) UIFont *detailsLabelFont __attribute__((deprecated("Use detailsLabel.font instead."))); 423 | @property (nonatomic, strong) UIColor *detailsLabelColor __attribute__((deprecated("Use detailsLabel.textColor instead."))); 424 | @property (assign, nonatomic) CGFloat opacity __attribute__((deprecated("Customize bezelView properties instead."))); 425 | @property (strong, nonatomic) UIColor *color __attribute__((deprecated("Customize the bezelView color instead."))); 426 | @property (assign, nonatomic) CGFloat xOffset __attribute__((deprecated("Set offset.x instead."))); 427 | @property (assign, nonatomic) CGFloat yOffset __attribute__((deprecated("Set offset.y instead."))); 428 | @property (assign, nonatomic) CGFloat cornerRadius __attribute__((deprecated("Set bezelView.layer.cornerRadius instead."))); 429 | @property (assign, nonatomic) BOOL dimBackground __attribute__((deprecated("Customize HUD background properties instead."))); 430 | @property (strong, nonatomic) UIColor *activityIndicatorColor __attribute__((deprecated("Use UIAppearance to customize UIActivityIndicatorView. E.g.: [UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil].color = [UIColor redColor];"))); 431 | @property (atomic, assign, readonly) CGSize size __attribute__((deprecated("Get the bezelView.frame.size instead."))); 432 | 433 | @end 434 | 435 | NS_ASSUME_NONNULL_END 436 | -------------------------------------------------------------------------------- /Pods/MBProgressHUD/README.mdown: -------------------------------------------------------------------------------- 1 | # MBProgressHUD 2 | 3 | [![Build Status](https://travis-ci.org/matej/MBProgressHUD.svg?branch=master)](https://travis-ci.org/matej/MBProgressHUD) [![codecov.io](https://codecov.io/github/matej/MBProgressHUD/coverage.svg?branch=master)](https://codecov.io/github/matej/MBProgressHUD?branch=master) 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) [![CocoaPods compatible](https://img.shields.io/cocoapods/v/MBProgressHUD.svg?style=flat)](https://cocoapods.org/pods/MBProgressHUD) [![License: MIT](https://img.shields.io/cocoapods/l/MBProgressHUD.svg?style=flat)](http://opensource.org/licenses/MIT) 5 | 6 | `MBProgressHUD` is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private `UIKit` `UIProgressHUD` with some additional features. 7 | 8 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1.png) 9 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2.png) 10 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3.png) 11 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4.png) 12 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5.png) 13 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6.png) 14 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7.png) 15 | 16 | **NOTE:** The class has recently undegone a major rewrite. The old version is available in the [legacy](https://github.com/jdg/MBProgressHUD/tree/legacy) branch, should you need it. 17 | 18 | ## Requirements 19 | 20 | `MBProgressHUD` works on iOS 6+ and requires ARC to build. It depends on the following Apple frameworks, which should already be included with most Xcode templates: 21 | 22 | * Foundation.framework 23 | * UIKit.framework 24 | * CoreGraphics.framework 25 | 26 | You will need the latest developer tools in order to build `MBProgressHUD`. Old Xcode versions might work, but compatibility will not be explicitly maintained. 27 | 28 | ## Adding MBProgressHUD to your project 29 | 30 | ### CocoaPods 31 | 32 | [CocoaPods](http://cocoapods.org) is the recommended way to add MBProgressHUD to your project. 33 | 34 | 1. Add a pod entry for MBProgressHUD to your Podfile `pod 'MBProgressHUD', '~> 1.0.0'` 35 | 2. Install the pod(s) by running `pod install`. 36 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 37 | 38 | ### Carthage 39 | 40 | 1. Add MBProgressHUD to your Cartfile. e.g., `github "jdg/MBProgressHUD" ~> 1.0.0` 41 | 2. Run `carthage update` 42 | 3. Follow the rest of the [standard Carthage installation instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to add MBProgressHUD to your project. 43 | 44 | ### Source files 45 | 46 | Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project. 47 | 48 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project. 49 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. 50 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 51 | 52 | ### Static library 53 | 54 | You can also add MBProgressHUD as a static library to your project or workspace. 55 | 56 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project. 57 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view"). 58 | 3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list. 59 | 4. Include MBProgressHUD wherever you need it with `#import `. 60 | 61 | ## Usage 62 | 63 | The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread. 64 | 65 | ```objective-c 66 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 67 | dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 68 | // Do something... 69 | dispatch_async(dispatch_get_main_queue(), ^{ 70 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 71 | }); 72 | }); 73 | ``` 74 | 75 | You can add the HUD on any view or window. It is however a good idea to avoid adding the HUD to certain `UIKit` views with complex view hierarchies - like `UITableView` or `UICollectionView`. Those can mutate their subviews in unexpected ways and thereby break HUD display. 76 | 77 | If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns. 78 | 79 | ```objective-c 80 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 81 | hud.mode = MBProgressHUDModeAnnularDeterminate; 82 | hud.labelText = @"Loading"; 83 | [self doSomethingInBackgroundWithProgressCallback:^(float progress) { 84 | hud.progress = progress; 85 | } completionCallback:^{ 86 | [hud hide:YES]; 87 | }]; 88 | ``` 89 | 90 | You can also use a `NSProgress` object and MBProgressHUD will update itself when there is progress reported through that object. 91 | 92 | ```objective-c 93 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 94 | hud.mode = MBProgressHUDModeAnnularDeterminate; 95 | hud.labelText = @"Loading"; 96 | NSProgress *progress = [self doSomethingInBackgroundCompletion:^{ 97 | [hud hide:YES]; 98 | }]; 99 | hud.progressObject = progress; 100 | ``` 101 | 102 | UI updates should always be done on the main thread. Some MBProgressHUD setters are however considered "thread safe" and can be called from background threads. Those also include `setMode:`, `setCustomView:`, `setLabelText:`, `setLabelFont:`, `setDetailsLabelText:`, `setDetailsLabelFont:` and `setProgress:`. 103 | 104 | If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task. 105 | 106 | ```objective-c 107 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 108 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC); 109 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 110 | // Do something... 111 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 112 | }); 113 | ``` 114 | 115 | You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes. 116 | 117 | For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h). 118 | 119 | 120 | ## License 121 | 122 | This code is distributed under the terms and conditions of the [MIT license](LICENSE). 123 | 124 | ## Change-log 125 | 126 | A brief summary of each MBProgressHUD release can be found in the [CHANGELOG](CHANGELOG.mdown). 127 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - MBProgressHUD 6 | 7 | SPEC CHECKSUMS: 8 | MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a 9 | 10 | COCOAPODS: 0.39.0 11 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Chintan.xcuserdatad/xcschemes/MBProgressHUD.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Chintan.xcuserdatad/xcschemes/Pods-iOS Alexa.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/Chintan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MBProgressHUD.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-iOS Alexa.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 987FBBCB3DE58F62C01657B955FAF6C1 21 | 22 | primary 23 | 24 | 25 | DBA6001481CEA0EBA031CC5C94508FAA 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/MBProgressHUD-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MBProgressHUD : NSObject 3 | @end 4 | @implementation PodsDummy_MBProgressHUD 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/MBProgressHUD-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/MBProgressHUD-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "MBProgressHUD.h" 4 | 5 | FOUNDATION_EXPORT double MBProgressHUDVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char MBProgressHUDVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/MBProgressHUD.modulemap: -------------------------------------------------------------------------------- 1 | framework module MBProgressHUD { 2 | umbrella header "MBProgressHUD-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MBProgressHUD/MBProgressHUD.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MBProgressHUD" "${PODS_ROOT}/Headers/Public" 3 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "QuartzCore" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MBProgressHUD 5 | 6 | Copyright © 2009-2016 Matej Bukovinski 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | Generated by CocoaPods - http://cocoapods.org 26 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright © 2009-2016 Matej Bukovinski 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | Title 37 | MBProgressHUD 38 | Type 39 | PSGroupSpecifier 40 | 41 | 42 | FooterText 43 | Generated by CocoaPods - http://cocoapods.org 44 | Title 45 | 46 | Type 47 | PSGroupSpecifier 48 | 49 | 50 | StringsTable 51 | Acknowledgements 52 | Title 53 | Acknowledgements 54 | 55 | 56 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_iOS_Alexa : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_iOS_Alexa 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "Pods-iOS Alexa/MBProgressHUD.framework" 88 | fi 89 | if [[ "$CONFIGURATION" == "Release" ]]; then 90 | install_framework "Pods-iOS Alexa/MBProgressHUD.framework" 91 | fi 92 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 63 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 66 | fi 67 | rm -f "$RESOURCES_TO_COPY" 68 | 69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 70 | then 71 | case "${TARGETED_DEVICE_FAMILY}" in 72 | 1,2) 73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 74 | ;; 75 | 1) 76 | TARGET_DEVICE_ARGS="--target-device iphone" 77 | ;; 78 | 2) 79 | TARGET_DEVICE_ARGS="--target-device ipad" 80 | ;; 81 | *) 82 | TARGET_DEVICE_ARGS="--target-device mac" 83 | ;; 84 | esac 85 | 86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 88 | while read line; do 89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 90 | XCASSET_FILES+=("$line") 91 | fi 92 | done <<<"$OTHER_XCASSETS" 93 | 94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 95 | fi 96 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_iOS_AlexaVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_iOS_AlexaVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/MBProgressHUD.framework/Headers" 4 | OTHER_LDFLAGS = $(inherited) -framework "MBProgressHUD" 5 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-iOS Alexa 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_iOS_Alexa { 2 | umbrella header "Pods-iOS Alexa-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 3 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/MBProgressHUD.framework/Headers" 4 | OTHER_LDFLAGS = $(inherited) -framework "MBProgressHUD" 5 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-iOS Alexa 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Alexa Voice Service 2 | 3 | This is an Alexa Voice Service example using Swift specifically for the iOS. It requires Swift 2 from XCode 7 or later. 4 | 5 | You will need to fill out the following three items found in Config.swift before running: 6 | 7 | ``` 8 | struct LoginWithAmazon { 9 | static let ClientId = "<< Client ID Here >>" 10 | static let ProductId = "<< Product ID Here >>" 11 | static let DeviceSerialNumber = "<< Device Serial Number Here >>" 12 | } 13 | ``` 14 | 15 | You will need to fill out the following items found in LoginViewController.m before running: 16 | 17 | ``` 18 | 19 | #define SCOPE_DATA @"{\"alexa:all\":{\"productID\":\"<< Product ID Here >>\",""\"productInstanceAttributes\":{\"deviceSerialNumber\":\"<< Device Serial Number Here >>\"}}}" 20 | 21 | ``` 22 | 23 | You will also need to change "APIKey" (This API Key needs to be generated from developer.amazon.com > Amazon Voice Service > Your Product > Security Profile > iOS Settings) & URL Scheme in Info.plist 24 | 25 | 26 | Special Thanks to https://github.com/carsonmcdonald/AVSExample-Swift 27 | -------------------------------------------------------------------------------- /iOS Alexa.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3627CF901D3D4D90000F24BD /* LoginWithAmazon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36D509F31D3D402600B48B9D /* LoginWithAmazon.framework */; }; 11 | 36D509DD1D3D3FA000B48B9D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509DC1D3D3FA000B48B9D /* AppDelegate.swift */; }; 12 | 36D509E21D3D3FA000B48B9D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 36D509E01D3D3FA000B48B9D /* Main.storyboard */; }; 13 | 36D509E41D3D3FA000B48B9D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 36D509E31D3D3FA000B48B9D /* Assets.xcassets */; }; 14 | 36D509E71D3D3FA000B48B9D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 36D509E51D3D3FA000B48B9D /* LaunchScreen.storyboard */; }; 15 | 36D509F81D3D402600B48B9D /* AVSUploader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509EF1D3D402600B48B9D /* AVSUploader.swift */; }; 16 | 36D509F91D3D402600B48B9D /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509F01D3D402600B48B9D /* Config.swift */; }; 17 | 36D509FA1D3D402600B48B9D /* SimplePCMRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509F11D3D402600B48B9D /* SimplePCMRecorder.swift */; }; 18 | 36D509FB1D3D402600B48B9D /* ISSharedData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509F21D3D402600B48B9D /* ISSharedData.swift */; }; 19 | 36D509FD1D3D402600B48B9D /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36D509F51D3D402600B48B9D /* HomeViewController.swift */; }; 20 | 36D509FE1D3D402600B48B9D /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36D509F71D3D402600B48B9D /* LoginViewController.m */; }; 21 | CCF010467AF09ED167579D67 /* Pods_iOS_Alexa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47665C9F665FD569F810C137 /* Pods_iOS_Alexa.framework */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 0CB5C83D8BF8C704890B920A /* Pods-iOS Alexa.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS Alexa.release.xcconfig"; path = "Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa.release.xcconfig"; sourceTree = ""; }; 26 | 36D509D91D3D3FA000B48B9D /* iOS Alexa.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS Alexa.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 36D509DC1D3D3FA000B48B9D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 28 | 36D509E11D3D3FA000B48B9D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 36D509E31D3D3FA000B48B9D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 36D509E61D3D3FA000B48B9D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 36D509E81D3D3FA000B48B9D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 36D509EF1D3D402600B48B9D /* AVSUploader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AVSUploader.swift; sourceTree = ""; }; 33 | 36D509F01D3D402600B48B9D /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; 34 | 36D509F11D3D402600B48B9D /* SimplePCMRecorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimplePCMRecorder.swift; sourceTree = ""; }; 35 | 36D509F21D3D402600B48B9D /* ISSharedData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ISSharedData.swift; sourceTree = ""; }; 36 | 36D509F31D3D402600B48B9D /* LoginWithAmazon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = LoginWithAmazon.framework; sourceTree = ""; }; 37 | 36D509F51D3D402600B48B9D /* HomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; 38 | 36D509F61D3D402600B48B9D /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = ""; }; 39 | 36D509F71D3D402600B48B9D /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = ""; }; 40 | 36D50A091D3D457400B48B9D /* iOS Alexa-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "iOS Alexa-Bridging-Header.h"; sourceTree = ""; }; 41 | 47665C9F665FD569F810C137 /* Pods_iOS_Alexa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_Alexa.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | C3C44E3EAA435E500BD720C4 /* Pods-iOS Alexa.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS Alexa.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa.debug.xcconfig"; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 36D509D61D3D3FA000B48B9D /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 3627CF901D3D4D90000F24BD /* LoginWithAmazon.framework in Frameworks */, 51 | CCF010467AF09ED167579D67 /* Pods_iOS_Alexa.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 2D569CA72BF7A9865F52826B /* Pods */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | C3C44E3EAA435E500BD720C4 /* Pods-iOS Alexa.debug.xcconfig */, 62 | 0CB5C83D8BF8C704890B920A /* Pods-iOS Alexa.release.xcconfig */, 63 | ); 64 | name = Pods; 65 | sourceTree = ""; 66 | }; 67 | 36D509D01D3D3FA000B48B9D = { 68 | isa = PBXGroup; 69 | children = ( 70 | 36D509DB1D3D3FA000B48B9D /* iOS Alexa */, 71 | 36D509DA1D3D3FA000B48B9D /* Products */, 72 | 2D569CA72BF7A9865F52826B /* Pods */, 73 | 6E6B3FF7987527087BFAB000 /* Frameworks */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | 36D509DA1D3D3FA000B48B9D /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 36D509D91D3D3FA000B48B9D /* iOS Alexa.app */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | 36D509DB1D3D3FA000B48B9D /* iOS Alexa */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 36D509EE1D3D402600B48B9D /* AVS */, 89 | 36D509F21D3D402600B48B9D /* ISSharedData.swift */, 90 | 36D509F31D3D402600B48B9D /* LoginWithAmazon.framework */, 91 | 36D509F41D3D402600B48B9D /* ViewController */, 92 | 36D509DC1D3D3FA000B48B9D /* AppDelegate.swift */, 93 | 36D509E01D3D3FA000B48B9D /* Main.storyboard */, 94 | 36D509E31D3D3FA000B48B9D /* Assets.xcassets */, 95 | 36D509E51D3D3FA000B48B9D /* LaunchScreen.storyboard */, 96 | 36D509E81D3D3FA000B48B9D /* Info.plist */, 97 | 36D50A091D3D457400B48B9D /* iOS Alexa-Bridging-Header.h */, 98 | ); 99 | path = "iOS Alexa"; 100 | sourceTree = ""; 101 | }; 102 | 36D509EE1D3D402600B48B9D /* AVS */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 36D509EF1D3D402600B48B9D /* AVSUploader.swift */, 106 | 36D509F01D3D402600B48B9D /* Config.swift */, 107 | 36D509F11D3D402600B48B9D /* SimplePCMRecorder.swift */, 108 | ); 109 | path = AVS; 110 | sourceTree = ""; 111 | }; 112 | 36D509F41D3D402600B48B9D /* ViewController */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 36D509F51D3D402600B48B9D /* HomeViewController.swift */, 116 | 36D509F61D3D402600B48B9D /* LoginViewController.h */, 117 | 36D509F71D3D402600B48B9D /* LoginViewController.m */, 118 | ); 119 | path = ViewController; 120 | sourceTree = ""; 121 | }; 122 | 6E6B3FF7987527087BFAB000 /* Frameworks */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 47665C9F665FD569F810C137 /* Pods_iOS_Alexa.framework */, 126 | ); 127 | name = Frameworks; 128 | sourceTree = ""; 129 | }; 130 | /* End PBXGroup section */ 131 | 132 | /* Begin PBXNativeTarget section */ 133 | 36D509D81D3D3FA000B48B9D /* iOS Alexa */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = 36D509EB1D3D3FA000B48B9D /* Build configuration list for PBXNativeTarget "iOS Alexa" */; 136 | buildPhases = ( 137 | 658C0015E1394F727D8C925E /* Check Pods Manifest.lock */, 138 | 36D509D51D3D3FA000B48B9D /* Sources */, 139 | 36D509D61D3D3FA000B48B9D /* Frameworks */, 140 | 36D509D71D3D3FA000B48B9D /* Resources */, 141 | BCF2750B4B556E1E46ED6CE9 /* Embed Pods Frameworks */, 142 | 2093F18315931B51AEE49051 /* Copy Pods Resources */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = "iOS Alexa"; 149 | productName = "iOS Alexa"; 150 | productReference = 36D509D91D3D3FA000B48B9D /* iOS Alexa.app */; 151 | productType = "com.apple.product-type.application"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | 36D509D11D3D3FA000B48B9D /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastSwiftUpdateCheck = 0730; 160 | LastUpgradeCheck = 0730; 161 | ORGANIZATIONNAME = Chintan; 162 | TargetAttributes = { 163 | 36D509D81D3D3FA000B48B9D = { 164 | CreatedOnToolsVersion = 7.3; 165 | DevelopmentTeam = 396UV3LCPE; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = 36D509D41D3D3FA000B48B9D /* Build configuration list for PBXProject "iOS Alexa" */; 170 | compatibilityVersion = "Xcode 3.2"; 171 | developmentRegion = English; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | Base, 176 | ); 177 | mainGroup = 36D509D01D3D3FA000B48B9D; 178 | productRefGroup = 36D509DA1D3D3FA000B48B9D /* Products */; 179 | projectDirPath = ""; 180 | projectRoot = ""; 181 | targets = ( 182 | 36D509D81D3D3FA000B48B9D /* iOS Alexa */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXResourcesBuildPhase section */ 188 | 36D509D71D3D3FA000B48B9D /* Resources */ = { 189 | isa = PBXResourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 36D509E71D3D3FA000B48B9D /* LaunchScreen.storyboard in Resources */, 193 | 36D509E41D3D3FA000B48B9D /* Assets.xcassets in Resources */, 194 | 36D509E21D3D3FA000B48B9D /* Main.storyboard in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXShellScriptBuildPhase section */ 201 | 2093F18315931B51AEE49051 /* Copy Pods Resources */ = { 202 | isa = PBXShellScriptBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | inputPaths = ( 207 | ); 208 | name = "Copy Pods Resources"; 209 | outputPaths = ( 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | shellPath = /bin/sh; 213 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-resources.sh\"\n"; 214 | showEnvVarsInLog = 0; 215 | }; 216 | 658C0015E1394F727D8C925E /* Check Pods Manifest.lock */ = { 217 | isa = PBXShellScriptBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | ); 221 | inputPaths = ( 222 | ); 223 | name = "Check Pods Manifest.lock"; 224 | outputPaths = ( 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | shellPath = /bin/sh; 228 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 229 | showEnvVarsInLog = 0; 230 | }; 231 | BCF2750B4B556E1E46ED6CE9 /* Embed Pods Frameworks */ = { 232 | isa = PBXShellScriptBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | ); 236 | inputPaths = ( 237 | ); 238 | name = "Embed Pods Frameworks"; 239 | outputPaths = ( 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | shellPath = /bin/sh; 243 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-iOS Alexa/Pods-iOS Alexa-frameworks.sh\"\n"; 244 | showEnvVarsInLog = 0; 245 | }; 246 | /* End PBXShellScriptBuildPhase section */ 247 | 248 | /* Begin PBXSourcesBuildPhase section */ 249 | 36D509D51D3D3FA000B48B9D /* Sources */ = { 250 | isa = PBXSourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 36D509F81D3D402600B48B9D /* AVSUploader.swift in Sources */, 254 | 36D509FB1D3D402600B48B9D /* ISSharedData.swift in Sources */, 255 | 36D509DD1D3D3FA000B48B9D /* AppDelegate.swift in Sources */, 256 | 36D509FA1D3D402600B48B9D /* SimplePCMRecorder.swift in Sources */, 257 | 36D509FE1D3D402600B48B9D /* LoginViewController.m in Sources */, 258 | 36D509F91D3D402600B48B9D /* Config.swift in Sources */, 259 | 36D509FD1D3D402600B48B9D /* HomeViewController.swift in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXSourcesBuildPhase section */ 264 | 265 | /* Begin PBXVariantGroup section */ 266 | 36D509E01D3D3FA000B48B9D /* Main.storyboard */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | 36D509E11D3D3FA000B48B9D /* Base */, 270 | ); 271 | name = Main.storyboard; 272 | sourceTree = ""; 273 | }; 274 | 36D509E51D3D3FA000B48B9D /* LaunchScreen.storyboard */ = { 275 | isa = PBXVariantGroup; 276 | children = ( 277 | 36D509E61D3D3FA000B48B9D /* Base */, 278 | ); 279 | name = LaunchScreen.storyboard; 280 | sourceTree = ""; 281 | }; 282 | /* End PBXVariantGroup section */ 283 | 284 | /* Begin XCBuildConfiguration section */ 285 | 36D509E91D3D3FA000B48B9D /* Debug */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ALWAYS_SEARCH_USER_PATHS = NO; 289 | CLANG_ANALYZER_NONNULL = YES; 290 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 291 | CLANG_CXX_LIBRARY = "libc++"; 292 | CLANG_ENABLE_MODULES = YES; 293 | CLANG_ENABLE_OBJC_ARC = YES; 294 | CLANG_WARN_BOOL_CONVERSION = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_EMPTY_BODY = YES; 298 | CLANG_WARN_ENUM_CONVERSION = YES; 299 | CLANG_WARN_INT_CONVERSION = YES; 300 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 301 | CLANG_WARN_UNREACHABLE_CODE = YES; 302 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 303 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 304 | COPY_PHASE_STRIP = NO; 305 | DEBUG_INFORMATION_FORMAT = dwarf; 306 | ENABLE_STRICT_OBJC_MSGSEND = YES; 307 | ENABLE_TESTABILITY = YES; 308 | GCC_C_LANGUAGE_STANDARD = gnu99; 309 | GCC_DYNAMIC_NO_PIC = NO; 310 | GCC_NO_COMMON_BLOCKS = YES; 311 | GCC_OPTIMIZATION_LEVEL = 0; 312 | GCC_PREPROCESSOR_DEFINITIONS = ( 313 | "DEBUG=1", 314 | "$(inherited)", 315 | ); 316 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 317 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 318 | GCC_WARN_UNDECLARED_SELECTOR = YES; 319 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 320 | GCC_WARN_UNUSED_FUNCTION = YES; 321 | GCC_WARN_UNUSED_VARIABLE = YES; 322 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 323 | MTL_ENABLE_DEBUG_INFO = YES; 324 | ONLY_ACTIVE_ARCH = YES; 325 | SDKROOT = iphoneos; 326 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 327 | }; 328 | name = Debug; 329 | }; 330 | 36D509EA1D3D3FA000B48B9D /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_ANALYZER_NONNULL = YES; 335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 336 | CLANG_CXX_LIBRARY = "libc++"; 337 | CLANG_ENABLE_MODULES = YES; 338 | CLANG_ENABLE_OBJC_ARC = YES; 339 | CLANG_WARN_BOOL_CONVERSION = YES; 340 | CLANG_WARN_CONSTANT_CONVERSION = YES; 341 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 342 | CLANG_WARN_EMPTY_BODY = YES; 343 | CLANG_WARN_ENUM_CONVERSION = YES; 344 | CLANG_WARN_INT_CONVERSION = YES; 345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 346 | CLANG_WARN_UNREACHABLE_CODE = YES; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = NO; 350 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 351 | ENABLE_NS_ASSERTIONS = NO; 352 | ENABLE_STRICT_OBJC_MSGSEND = YES; 353 | GCC_C_LANGUAGE_STANDARD = gnu99; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 356 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 357 | GCC_WARN_UNDECLARED_SELECTOR = YES; 358 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 359 | GCC_WARN_UNUSED_FUNCTION = YES; 360 | GCC_WARN_UNUSED_VARIABLE = YES; 361 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 362 | MTL_ENABLE_DEBUG_INFO = NO; 363 | SDKROOT = iphoneos; 364 | VALIDATE_PRODUCT = YES; 365 | }; 366 | name = Release; 367 | }; 368 | 36D509EC1D3D3FA000B48B9D /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | baseConfigurationReference = C3C44E3EAA435E500BD720C4 /* Pods-iOS Alexa.debug.xcconfig */; 371 | buildSettings = { 372 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 373 | CODE_SIGN_IDENTITY = "iPhone Developer"; 374 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 375 | FRAMEWORK_SEARCH_PATHS = ( 376 | "$(inherited)", 377 | "$(PROJECT_DIR)/iOS", 378 | Alexa, 379 | "$(PROJECT_DIR)/iOS", 380 | Alexa, 381 | "$(PROJECT_DIR)/iOS", 382 | Alexa, 383 | "$(PROJECT_DIR)/iOS", 384 | Alexa, 385 | ); 386 | INFOPLIST_FILE = "iOS Alexa/Info.plist"; 387 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 389 | PRODUCT_BUNDLE_IDENTIFIER = "com.chintan.iOS-Alexa"; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | PROVISIONING_PROFILE = ""; 392 | SWIFT_OBJC_BRIDGING_HEADER = "iOS Alexa/iOS Alexa-Bridging-Header.h"; 393 | }; 394 | name = Debug; 395 | }; 396 | 36D509ED1D3D3FA000B48B9D /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | baseConfigurationReference = 0CB5C83D8BF8C704890B920A /* Pods-iOS Alexa.release.xcconfig */; 399 | buildSettings = { 400 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 401 | CODE_SIGN_IDENTITY = "iPhone Developer"; 402 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(inherited)", 405 | "$(PROJECT_DIR)/iOS", 406 | Alexa, 407 | "$(PROJECT_DIR)/iOS", 408 | Alexa, 409 | "$(PROJECT_DIR)/iOS", 410 | Alexa, 411 | "$(PROJECT_DIR)/iOS", 412 | Alexa, 413 | ); 414 | INFOPLIST_FILE = "iOS Alexa/Info.plist"; 415 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 417 | PRODUCT_BUNDLE_IDENTIFIER = "com.chintan.iOS-Alexa"; 418 | PRODUCT_NAME = "$(TARGET_NAME)"; 419 | PROVISIONING_PROFILE = ""; 420 | SWIFT_OBJC_BRIDGING_HEADER = "iOS Alexa/iOS Alexa-Bridging-Header.h"; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | 36D509D41D3D3FA000B48B9D /* Build configuration list for PBXProject "iOS Alexa" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 36D509E91D3D3FA000B48B9D /* Debug */, 431 | 36D509EA1D3D3FA000B48B9D /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 36D509EB1D3D3FA000B48B9D /* Build configuration list for PBXNativeTarget "iOS Alexa" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 36D509EC1D3D3FA000B48B9D /* Debug */, 440 | 36D509ED1D3D3FA000B48B9D /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 36D509D11D3D3FA000B48B9D /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /iOS Alexa.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iOS Alexa.xcodeproj/project.xcworkspace/xcuserdata/Chintan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa.xcodeproj/project.xcworkspace/xcuserdata/Chintan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iOS Alexa.xcodeproj/xcuserdata/Chintan.xcuserdatad/xcschemes/iOS Alexa.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /iOS Alexa.xcodeproj/xcuserdata/Chintan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iOS Alexa.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 36D509D81D3D3FA000B48B9D 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /iOS Alexa.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /iOS Alexa.xcworkspace/xcuserdata/Chintan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa.xcworkspace/xcuserdata/Chintan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iOS Alexa/AVS/AVSUploader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AVSUploader.swift 3 | // AVSExample 4 | // 5 | 6 | import Foundation 7 | 8 | struct PartData { 9 | var headers: [String:String] 10 | var data: NSData 11 | } 12 | 13 | class AVSUploader: NSObject, NSURLSessionTaskDelegate { 14 | 15 | var authToken:String? 16 | var jsonData:String? 17 | var audioData:NSData? 18 | 19 | var errorHandler: ((error:NSError) -> Void)? 20 | var progressHandler: ((progress:Double) -> Void)? 21 | var successHandler: ((data:NSData, parts:[PartData]) -> Void)? 22 | 23 | private var session: NSURLSession! 24 | 25 | func start() throws { 26 | if self.authToken == nil || self.jsonData == nil || self.audioData == nil { 27 | throw NSError(domain: Config.Error.ErrorDomain, code: Config.Error.AVSUploaderSetupIncompleteErrorCode, userInfo: [NSLocalizedDescriptionKey : "AVS upload options not set"]) 28 | } 29 | 30 | if self.session == nil { 31 | self.session = NSURLSession(configuration: NSURLSession.sharedSession().configuration, delegate: self, delegateQueue: nil) 32 | } 33 | 34 | self.postRecording(self.authToken!, jsonData: self.jsonData!, audioData: self.audioData!) 35 | } 36 | 37 | private func parseResponse(data:NSData, boundry:String) -> [PartData] { 38 | 39 | let innerBoundry = "\(boundry)\r\n".dataUsingEncoding(NSUTF8StringEncoding)! 40 | let endBoundry = "\r\n\(boundry)--\r\n".dataUsingEncoding(NSUTF8StringEncoding)! 41 | 42 | var innerRanges = [NSRange]() 43 | var lastStartingLocation = 0 44 | 45 | var boundryRange = data.rangeOfData(innerBoundry, options: NSDataSearchOptions(), range: NSMakeRange(lastStartingLocation, data.length)) 46 | while(boundryRange.location != NSNotFound) { 47 | 48 | lastStartingLocation = boundryRange.location + boundryRange.length 49 | boundryRange = data.rangeOfData(innerBoundry, options: NSDataSearchOptions(), range: NSMakeRange(lastStartingLocation, data.length - lastStartingLocation)) 50 | 51 | if boundryRange.location != NSNotFound { 52 | innerRanges.append(NSMakeRange(lastStartingLocation, boundryRange.location - innerBoundry.length)) 53 | } else { 54 | innerRanges.append(NSMakeRange(lastStartingLocation, data.length - lastStartingLocation)) 55 | } 56 | } 57 | 58 | var partData = [PartData]() 59 | 60 | for innerRange in innerRanges { 61 | let innerData = data.subdataWithRange(innerRange) 62 | 63 | let headerRange = innerData.rangeOfData("\r\n\r\n".dataUsingEncoding(NSUTF8StringEncoding)!, options: NSDataSearchOptions(), range: NSMakeRange(0, innerRange.length)) 64 | 65 | var headers = [String:String]() 66 | if let headerData = NSString(data: innerData.subdataWithRange(NSMakeRange(0, headerRange.location)), encoding: NSUTF8StringEncoding) as? String { 67 | let headerLines = headerData.characters.split{$0 == "\r\n"}.map{String($0)} 68 | for headerLine in headerLines { 69 | let headerSplit = headerLine.characters.split{ $0 == ":" }.map{String($0)} 70 | headers[headerSplit[0]] = headerSplit[1].stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) 71 | } 72 | } 73 | 74 | let startLocation = headerRange.location + headerRange.length 75 | let contentData = innerData.subdataWithRange(NSMakeRange(startLocation, innerRange.length - startLocation)) 76 | 77 | let endContentRange = contentData.rangeOfData(endBoundry, options: NSDataSearchOptions(), range: NSMakeRange(0, contentData.length)) 78 | if endContentRange.location != NSNotFound { 79 | partData.append(PartData(headers: headers, data: contentData.subdataWithRange(NSMakeRange(0, endContentRange.location)))) 80 | } else { 81 | partData.append(PartData(headers: headers, data: contentData)) 82 | } 83 | } 84 | 85 | return partData 86 | } 87 | 88 | private func postRecording(authToken:String, jsonData:String, audioData:NSData) { 89 | let request = NSMutableURLRequest(URL: NSURL(string: "https://access-alexa-na.amazon.com/v1/avs/speechrecognizer/recognize")!) 90 | request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringCacheData 91 | request.HTTPShouldHandleCookies = false 92 | request.timeoutInterval = 60 93 | request.HTTPMethod = "POST" 94 | 95 | request.setValue("Bearer \(authToken)", forHTTPHeaderField: "Authorization") 96 | 97 | let boundry = NSUUID().UUIDString 98 | let contentType = "multipart/form-data; boundary=\(boundry)" 99 | 100 | request.setValue(contentType, forHTTPHeaderField: "Content-Type") 101 | 102 | let bodyData = NSMutableData() 103 | 104 | bodyData.appendData("--\(boundry)\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 105 | bodyData.appendData("Content-Disposition: form-data; name=\"metadata\"\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 106 | bodyData.appendData("Content-Type: application/json; charset=UTF-8\r\n\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 107 | bodyData.appendData(jsonData.dataUsingEncoding(NSUTF8StringEncoding)!) 108 | bodyData.appendData("\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 109 | 110 | bodyData.appendData("--\(boundry)\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 111 | bodyData.appendData("Content-Disposition: form-data; name=\"audio\"\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 112 | bodyData.appendData("Content-Type: audio/L16; rate=16000; channels=1\r\n\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 113 | bodyData.appendData(audioData) 114 | bodyData.appendData("\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 115 | 116 | bodyData.appendData("--\(boundry)--\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) 117 | 118 | let uploadTask = self.session.uploadTaskWithRequest(request, fromData: bodyData) { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in 119 | 120 | self.progressHandler?(progress: 100.0) 121 | 122 | if let e = error { 123 | self.errorHandler?(error: e) 124 | } else { 125 | if let httpResponse = response as? NSHTTPURLResponse { 126 | 127 | if httpResponse.statusCode >= 200 && httpResponse.statusCode <= 299 { 128 | if let responseData = data, let contentTypeHeader = httpResponse.allHeaderFields["Content-Type"] { 129 | var boundry: String? 130 | let ctbRange = contentTypeHeader.rangeOfString("boundary=.*?;", options: .RegularExpressionSearch) 131 | if ctbRange.location != NSNotFound { 132 | let boundryNSS = contentTypeHeader.substringWithRange(ctbRange) as NSString 133 | boundry = boundryNSS.substringWithRange(NSRange(location: 9, length: boundryNSS.length - 10)) 134 | } 135 | 136 | if let b = boundry { 137 | self.successHandler?(data: responseData, parts:self.parseResponse(responseData, boundry: b)) 138 | } else { 139 | self.errorHandler?(error: NSError(domain: Config.Error.ErrorDomain, code: Config.Error.AVSResponseBorderParseErrorCode, userInfo: [NSLocalizedDescriptionKey : "Could not find boundry in AVS response"])) 140 | } 141 | } 142 | } else { 143 | var message: NSString? 144 | if data != nil { 145 | do { 146 | if let errorDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions(rawValue: 0)) as? [String:AnyObject], let errorValue = errorDictionary["error"] as? [String:String], let errorMessage = errorValue["message"] { 147 | 148 | message = errorMessage 149 | 150 | } else { 151 | message = NSString(data: data!, encoding: NSUTF8StringEncoding) 152 | } 153 | } catch { 154 | message = NSString(data: data!, encoding: NSUTF8StringEncoding) 155 | } 156 | } 157 | let finalMessage = message == nil ? "" : message! 158 | self.errorHandler?(error: NSError(domain: Config.Error.ErrorDomain, code: Config.Error.AVSAPICallErrorCode, userInfo: [NSLocalizedDescriptionKey : "AVS error: \(httpResponse.statusCode) - \(finalMessage)"])) 159 | } 160 | 161 | } 162 | } 163 | } 164 | 165 | uploadTask.resume() 166 | } 167 | 168 | func URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) { 169 | 170 | self.progressHandler?(progress:Double(Double(totalBytesSent) / Double(totalBytesExpectedToSend)) * 100.0) 171 | 172 | } 173 | } -------------------------------------------------------------------------------- /iOS Alexa/AVS/Config.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Config.swift 3 | // AVSExample 4 | // 5 | 6 | import Foundation 7 | 8 | struct Config { 9 | 10 | struct LoginWithAmazon { 11 | static let ClientId = "<< Client ID Here >>" 12 | static let ProductId = "<< Product ID Here >>" 13 | static let DeviceSerialNumber = "<< Device Serial Number Here >>" 14 | } 15 | 16 | struct Debug { 17 | static let General = false 18 | static let Errors = true 19 | static let HTTPRequest = false 20 | static let HTTPResponse = false 21 | } 22 | 23 | struct Error { 24 | static let ErrorDomain = "net.ioncannon.SimplePCMRecorderError" 25 | 26 | static let PCMSetupIncompleteErrorCode = 1 27 | 28 | static let AVSUploaderSetupIncompleteErrorCode = 2 29 | static let AVSAPICallErrorCode = 3 30 | static let AVSResponseBorderParseErrorCode = 4 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /iOS Alexa/AVS/SimplePCMRecorder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimplePCMRecorder.swift 3 | // AVSExample 4 | // 5 | 6 | import Foundation 7 | import CoreAudio 8 | import AudioToolbox 9 | 10 | struct RecorderState { 11 | var setupComplete: Bool 12 | var dataFormat: AudioStreamBasicDescription 13 | var queue: UnsafeMutablePointer 14 | var buffers: [AudioQueueBufferRef] 15 | var recordFile: AudioFileID 16 | var bufferByteSize: UInt32 17 | var currentPacket: Int64 18 | var isRunning: Bool 19 | var recordPacket: Int64 20 | var errorHandler: ((error:NSError) -> Void)? 21 | } 22 | 23 | class SimplePCMRecorder { 24 | 25 | private var recorderState: RecorderState 26 | 27 | init(numberBuffers:Int) { 28 | self.recorderState = RecorderState( 29 | setupComplete: false, 30 | dataFormat: AudioStreamBasicDescription(), 31 | queue: UnsafeMutablePointer.alloc(1), 32 | buffers: Array(count: numberBuffers, repeatedValue: nil), 33 | recordFile: AudioFileID(), 34 | bufferByteSize: 0, 35 | currentPacket: 0, 36 | isRunning: false, 37 | recordPacket: 0, 38 | errorHandler: nil) 39 | } 40 | 41 | deinit { 42 | self.recorderState.queue.dealloc(1) 43 | } 44 | 45 | func setupForRecording(outputFileName:String, sampleRate:Float64, channels:UInt32, bitsPerChannel:UInt32, errorHandler: ((error:NSError) -> Void)?) throws { 46 | self.recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM 47 | self.recorderState.dataFormat.mSampleRate = sampleRate 48 | self.recorderState.dataFormat.mChannelsPerFrame = channels 49 | self.recorderState.dataFormat.mBitsPerChannel = bitsPerChannel 50 | self.recorderState.dataFormat.mFramesPerPacket = 1 51 | self.recorderState.dataFormat.mBytesPerFrame = self.recorderState.dataFormat.mChannelsPerFrame * (self.recorderState.dataFormat.mBitsPerChannel / 8) 52 | self.recorderState.dataFormat.mBytesPerPacket = self.recorderState.dataFormat.mBytesPerFrame * self.recorderState.dataFormat.mFramesPerPacket 53 | 54 | self.recorderState.dataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked 55 | 56 | self.recorderState.errorHandler = errorHandler 57 | 58 | try osReturningCall { AudioFileCreateWithURL(NSURL(fileURLWithPath: outputFileName), kAudioFileWAVEType, &self.recorderState.dataFormat, AudioFileFlags.DontPageAlignAudioData.union(.EraseFile), &self.recorderState.recordFile) } 59 | 60 | self.recorderState.setupComplete = true 61 | } 62 | 63 | func startRecording() throws { 64 | 65 | guard self.recorderState.setupComplete else { throw NSError(domain: Config.Error.ErrorDomain, code: Config.Error.PCMSetupIncompleteErrorCode, userInfo: [NSLocalizedDescriptionKey : "Setup needs to be called before starting"]) } 66 | 67 | let osAQNI = AudioQueueNewInput(&self.recorderState.dataFormat, { (inUserData:UnsafeMutablePointer, inAQ:AudioQueueRef, inBuffer:AudioQueueBufferRef, inStartTime:UnsafePointer, inNumPackets:UInt32, inPacketDesc:UnsafePointer) -> Void in 68 | 69 | let internalRSP = unsafeBitCast(inUserData, UnsafeMutablePointer.self) 70 | 71 | if inNumPackets > 0 { 72 | var packets = inNumPackets 73 | 74 | let os = AudioFileWritePackets(internalRSP.memory.recordFile, false, inBuffer.memory.mAudioDataByteSize, inPacketDesc, internalRSP.memory.recordPacket, &packets, inBuffer.memory.mAudioData) 75 | if os != 0 && internalRSP.memory.errorHandler != nil { 76 | internalRSP.memory.errorHandler!(error:NSError(domain: NSOSStatusErrorDomain, code: Int(os), userInfo: nil)) 77 | } 78 | 79 | internalRSP.memory.recordPacket += Int64(packets) 80 | } 81 | 82 | if internalRSP.memory.isRunning { 83 | let os = AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, nil) 84 | if os != 0 && internalRSP.memory.errorHandler != nil { 85 | internalRSP.memory.errorHandler!(error:NSError(domain: NSOSStatusErrorDomain, code: Int(os), userInfo: nil)) 86 | } 87 | } 88 | 89 | }, &self.recorderState, nil, nil, 0, self.recorderState.queue) 90 | 91 | guard osAQNI == 0 else { throw NSError(domain: NSOSStatusErrorDomain, code: Int(osAQNI), userInfo: nil) } 92 | 93 | let bufferByteSize = try self.computeRecordBufferSize(self.recorderState.dataFormat, seconds: 0.5) 94 | for (var i = 0; i < self.recorderState.buffers.count; ++i) { 95 | try osReturningCall { AudioQueueAllocateBuffer(self.recorderState.queue.memory, UInt32(bufferByteSize), &self.recorderState.buffers[i]) } 96 | 97 | try osReturningCall { AudioQueueEnqueueBuffer(self.recorderState.queue.memory, self.recorderState.buffers[i], 0, nil) } 98 | } 99 | 100 | try osReturningCall { AudioQueueStart(self.recorderState.queue.memory, nil) } 101 | 102 | self.recorderState.isRunning = true 103 | } 104 | 105 | func stopRecording() throws { 106 | self.recorderState.isRunning = false 107 | 108 | try osReturningCall { AudioQueueStop(self.recorderState.queue.memory, true) } 109 | try osReturningCall { AudioQueueDispose(self.recorderState.queue.memory, true) } 110 | try osReturningCall { AudioFileClose(self.recorderState.recordFile) } 111 | } 112 | 113 | private func computeRecordBufferSize(format:AudioStreamBasicDescription, seconds:Double) throws -> Int { 114 | 115 | let framesNeededForBufferTime = Int(ceil(seconds * format.mSampleRate)) 116 | 117 | if format.mBytesPerFrame > 0 { 118 | return framesNeededForBufferTime * Int(format.mBytesPerFrame) 119 | } else { 120 | var maxPacketSize = UInt32(0) 121 | 122 | if format.mBytesPerPacket > 0 { 123 | maxPacketSize = format.mBytesPerPacket 124 | } else { 125 | try self.getAudioQueueProperty(kAudioQueueProperty_MaximumOutputPacketSize, value: &maxPacketSize) 126 | } 127 | 128 | var packets = 0 129 | if format.mFramesPerPacket > 0 { 130 | packets = framesNeededForBufferTime / Int(format.mFramesPerPacket) 131 | } else { 132 | packets = framesNeededForBufferTime 133 | } 134 | 135 | if packets == 0 { 136 | packets = 1 137 | } 138 | 139 | return packets * Int(maxPacketSize) 140 | } 141 | 142 | } 143 | 144 | private func osReturningCall(osCall: () -> OSStatus) throws { 145 | let os = osCall() 146 | if os != 0 { 147 | throw NSError(domain: NSOSStatusErrorDomain, code: Int(os), userInfo: nil) 148 | } 149 | } 150 | // 151 | // func getInputPower() -> Int 152 | // { 153 | // var levelMeterSize = sizeof(AudioQueueLevelMeterState) 154 | // try! getAudioQueueProperty(kAudioQueueProperty_CurrentLevelMeterDB, value: &levelMeterSize) 155 | // return levelMeterSize 156 | // } 157 | 158 | private func getAudioQueueProperty(propertyId:AudioQueuePropertyID, inout value:T) throws { 159 | 160 | let propertySize = UnsafeMutablePointer.alloc(1) 161 | propertySize.memory = UInt32(sizeof(T)) 162 | 163 | let os = AudioQueueGetProperty(self.recorderState.queue.memory, 164 | propertyId, 165 | &value, 166 | propertySize) 167 | 168 | propertySize.dealloc(1) 169 | 170 | guard os == 0 else { throw NSError(domain: NSOSStatusErrorDomain, code: Int(os), userInfo: nil) } 171 | 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /iOS Alexa/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // iOS Alexa 4 | // 5 | // Created by Chintan Prajapati on 13/05/16. 6 | // Copyright © 2016 Chintan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MBProgressHUD 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | 18 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 19 | // Override point for customization after application launch. 20 | application.idleTimerDisabled = true 21 | return true 22 | } 23 | 24 | func applicationWillResignActive(application: UIApplication) { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | } 28 | 29 | func applicationDidEnterBackground(application: UIApplication) { 30 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | func applicationWillEnterForeground(application: UIApplication) { 35 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 36 | } 37 | 38 | func applicationDidBecomeActive(application: UIApplication) { 39 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 40 | } 41 | 42 | func applicationWillTerminate(application: UIApplication) { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 47 | MBProgressHUD.showHUDAddedTo((window?.rootViewController!.view)!, animated: true) 48 | return AIMobileLib.handleOpenURL(url, sourceApplication: sourceApplication) 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/LoginButtonIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "btnLWA_gold_314x72.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/LoginButtonIcon.imageset/btnLWA_gold_314x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/Assets.xcassets/LoginButtonIcon.imageset/btnLWA_gold_314x72.png -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/MicIcon.imageset/1463769285_microphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/Assets.xcassets/MicIcon.imageset/1463769285_microphone.png -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/MicIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1463769285_microphone.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/StopIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Untitled11111.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /iOS Alexa/Assets.xcassets/StopIcon.imageset/Untitled11111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/Assets.xcassets/StopIcon.imageset/Untitled11111.png -------------------------------------------------------------------------------- /iOS Alexa/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /iOS Alexa/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 68 | 74 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /iOS Alexa/ISSharedData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ISSharedData.swift 3 | // iOS Alexa 4 | // 5 | // Created by Chintan Prajapati on 24/05/16. 6 | // Copyright © 2016 Chintan. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public class ISSharedData : NSObject { 12 | public static let sharedInstance = ISSharedData() 13 | 14 | public var accessToken:String? 15 | } -------------------------------------------------------------------------------- /iOS Alexa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | APIKey 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLName 29 | com.chintan.iOS-Alexa 30 | CFBundleURLSchemes 31 | 32 | amzn-com.chintan.iOS-Alexa 33 | 34 | 35 | 36 | CFBundleVersion 37 | 1 38 | LSRequiresIPhoneOS 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIMainStoryboardFile 43 | Main 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Headers/AIAuthenticationDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | @class AIError; 16 | 17 | #pragma mark - API 18 | 19 | /** 20 | These constants identify which API succeeded or failed when calling AIAuthenticationDelegate. The value identifying 21 | the API is passed in the APIResult and APIError objects. 22 | 23 | @since 1.0 24 | */ 25 | typedef NS_ENUM(NSUInteger, API) { 26 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:]` */ 27 | kAPIAuthorizeUser = 1, 28 | /** Refers to `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` */ 29 | kAPIGetAccessToken = 2, 30 | /** Refers to `[AIMobileLib clearAuthorizationState:]` */ 31 | kAPIClearAuthorizationState = 3, 32 | /** Refers to `[AIMobileLib getProfile:]` */ 33 | kAPIGetProfile = 4, 34 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:options]` */ 35 | kAPIGetAuthorizationCode = 5 36 | }; 37 | 38 | #pragma mark - APIResult 39 | /** 40 | This class encapsulates success information from an AIMobileLib API call. 41 | */ 42 | @interface APIResult : NSObject 43 | 44 | - (id)initResultForAPI:(API)anAPI andResult:(id)theResult; 45 | 46 | /** 47 | The result object returned from the API on success. The API result can be `nil`, an `NSDictionary`, or an `NSString` 48 | depending upon which API created the APIResult. 49 | 50 | - `[AIMobileLib authorizeUserForScopes:delegate:]` : Passes `nil` as the result to the delegate. 51 | - `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` : Passes an access token as an `NSString` object 52 | to the delegate. 53 | - `[AIMobileLib clearAuthorizationState:]` : Passes nil as the result to the delegate. 54 | - `[AIMobileLib getProfile:]` : Passes profile data in an `NSDictionary` object to the delegate. See the API description 55 | for information on the key:value pairs expected in profile dictionary. 56 | 57 | @since 1.0 58 | */ 59 | @property (retain) id result; 60 | 61 | /** 62 | The API returning the result. 63 | 64 | @since 1.0 65 | */ 66 | @property API api; 67 | 68 | @end 69 | 70 | #pragma mark - APIError 71 | 72 | /** 73 | This class encapsulates the failure result from an AIMobileLib API call. 74 | */ 75 | @interface APIError : NSObject 76 | 77 | - (id)initErrorForAPI:(API)anAPI andError:(id)theErrorObject; 78 | 79 | /** 80 | The error object returned from the API on failure. 81 | 82 | @see See AIError for more details. 83 | 84 | @since 1.0 85 | */ 86 | @property (retain) AIError *error; 87 | 88 | /** 89 | The API which is returning the error. 90 | 91 | @since 1.0 92 | */ 93 | @property API api; 94 | 95 | @end 96 | 97 | #pragma mark - AIAuthenticationDelegate 98 | /** 99 | Applications calling AIMobileLib APIs must implement the methods of this protocol to receive success and failure 100 | information. 101 | */ 102 | @protocol AIAuthenticationDelegate 103 | 104 | @required 105 | 106 | /** 107 | The APIs call this delegate method with the result when it completes successfully. 108 | 109 | @param apiResult An APIResult object containing the information about the calling API and the result generated. 110 | @see See APIResult for more information on the content of the apiResult. 111 | @since 1.0 112 | */ 113 | - (void)requestDidSucceed:(APIResult *)apiResult; 114 | 115 | 116 | /** 117 | The APIs call this delegate method with the result when it fails. 118 | 119 | @param errorResponse An APIResult object containing the information about the API and the error that occurred. 120 | @see See APIError for more information on the content of the result. 121 | @since 1.0 122 | */ 123 | - (void)requestDidFail:(APIError *)errorResponse; 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Headers/AIError.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #pragma mark - Error codes 16 | 17 | /** 18 | No error, initial value. 19 | */ 20 | extern const NSUInteger kAINoError; 21 | 22 | /** 23 | A valid refresh token was not found. 24 | 25 | The refresh token stored in the SDK is invalid, expired, revoked, does not match 26 | the redirection URI used in the authorization request, does not have the required scopes, or was issued to another 27 | client. `[AIMobileLib getProfile:]` and `[getAccessTokenForScopes:withOverrideParams:delegate:]` can return this 28 | error. 29 | 30 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to request 31 | authorization, or call `[AIMobileLib clearAuthorizationState:]` to logout the user. 32 | */ 33 | extern const NSUInteger kAIApplicationNotAuthorized; 34 | 35 | /** 36 | An error occurred on the server. 37 | 38 | The server encountered an error while completing the request, or the SDK received an unknown response from the server. 39 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 40 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 41 | 42 | Generally with this type of error, the app can allow the user to retry the last action. 43 | */ 44 | extern const NSUInteger kAIServerError; 45 | 46 | /** 47 | The user canceled the login page. 48 | 49 | The user pressed cancel while on the login or the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 50 | return this error. 51 | 52 | Generally with this type of error, the app can allow the user to login again. 53 | */ 54 | extern const NSUInteger kAIErrorUserInterrupted; 55 | 56 | /** 57 | The resource owner or authorization server denied the request. 58 | 59 | The user declined to authorize the app on the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 60 | return this error. 61 | 62 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to 63 | request authorization. 64 | */ 65 | extern const NSUInteger kAIAccessDenied; 66 | 67 | /** 68 | The SDK encountered an error on the device. 69 | 70 | The SDK returns this when there is a problem with the Keychain. `[AIMobileLib getProfile:]`, 71 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 72 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 73 | 74 | Generally with this type of error, the app can call `[AIMobileLib clearAuthorizationState:]` to reset the Keychain. 75 | */ 76 | extern const NSUInteger kAIDeviceError; 77 | 78 | /** 79 | One of the API parameters is invalid. 80 | 81 | The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, 82 | or is otherwise malformed. 83 | 84 | Check your method parameters and try again. All APIs can return this error. 85 | */ 86 | extern const NSUInteger kAIInvalidInput; 87 | 88 | /** 89 | A network error occurred, possibly due to the user being offline. 90 | 91 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 92 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 93 | 94 | Generally with this type of error, the app can ask the user to check their network connections. 95 | */ 96 | extern const NSUInteger kAINetworkError; 97 | 98 | /** 99 | The client is not authorized to request an authorization code using this method. 100 | 101 | The app is not authorized to make this call. Make sure the registered Bundle identifier matches your app, and that you 102 | have a valid APIKey property in the app property list. 103 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 104 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 105 | */ 106 | extern const NSUInteger kAIUnauthorizedClient; 107 | 108 | /** 109 | An internal error occurred in the SDK. 110 | 111 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 112 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 113 | 114 | Generally these errors cannot be handled by app. Please contact us to report recurring internal errors. 115 | */ 116 | extern const NSUInteger kAIInternalError; 117 | 118 | /** 119 | An version error occurred while the SDK version is not supported for LWA SSO. 120 | Only `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 121 | */ 122 | extern const NSUInteger kAIVersionDenied; 123 | 124 | #pragma mark - AIError 125 | 126 | /** 127 | This class encapsulates the error information generated by the SDK. An AIError object includes the error code and a 128 | meaningful error message. The error code constants are available in the header file. 129 | */ 130 | @interface AIError : NSObject 131 | 132 | /** 133 | The error code for the error encountered by the API. 134 | 135 | @since 1.0 136 | */ 137 | @property NSUInteger code; 138 | 139 | /** 140 | The readable message corresponding to the error code. 141 | 142 | @since 1.0 143 | */ 144 | @property (retain) NSString *message; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Headers/AIMobileLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIError.h" 16 | #import "AIAuthenticationDelegate.h" 17 | 18 | /** 19 | Key name for defining whether to force a refresh of the access token. 20 | 21 | Pass this key with a string value of "YES" to `getAccessTokenForScopes:withOverrideParams:delegate:` to force the 22 | method to refresh the access token. 23 | */ 24 | extern const NSString *kForceRefresh; 25 | 26 | /** 27 | Key name for defining whether sandbox mode is on. 28 | 29 | Pass this key with a string value of "YES" to `authorizeUserForScopes:delegate:options:` to switch to the sandbox mode. 30 | */ 31 | extern const NSString *kAIOptionSandboxMode; 32 | 33 | /** 34 | Key name for defining the scope data parameter. 35 | 36 | Pass this key with a Json encoded string of scope data to`authorizeUserForScopes:delegate:options` as required by certain 37 | types of Amazon services. 38 | */ 39 | extern const NSString *kAIOptionScopeData; 40 | 41 | /** 42 | Key name for defining whether to return authorization code. 43 | 44 | Pass this key with a BOOL value of `YES` to `authorizeUserForScopes:delegate:options` to get back an authorization code. 45 | */ 46 | extern const NSString *kAIOptionReturnAuthCode; 47 | 48 | /** 49 | Key name for defining the SPOP code challenge parameter. 50 | 51 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 52 | with kAIOptionReturnAuthCode as `YES`. 53 | */ 54 | extern const NSString *kAIOptionCodeChallenge; 55 | 56 | /** 57 | Key name for defining the SPOP code challenge method parameter. (Optional) 58 | 59 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 60 | with kAIOptionReturnAuthCode as `YES`. 61 | */ 62 | extern const NSString *kAIOptionCodeChallengeMethod; 63 | 64 | /** 65 | AIMobileLib is a static class that contains Login with Amazon APIs. 66 | 67 | This class provides APIs for getting authorization from users, getting profile information, clearing authorization 68 | state, and getting authorization tokens to access secure data. 69 | */ 70 | @interface AIMobileLib : NSObject 71 | 72 | /** 73 | Allows the user to login and, if necessary, authorize the app for the requested scopes. 74 | 75 | Use this method to request authorization from the user for the required scopes. If the user has not logged in, they 76 | will see a login page. Afterward, if they have not previously approved these scopes for your app, they will see a 77 | consent page. 78 | 79 | The sign-in page is displayed in Safari, so there will be a visible switch from the app to Safari. After the user 80 | signs in on the browser, they are redirected back to the app. The app must define 81 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` in the app delegate and call the 82 | `handleOpenURL:sourceApplication:` API from that delegate method. This allows the SDK to get the login information 83 | from the Safari web browser. 84 | 85 | Scopes that can be used with this API are: 86 | 87 | - "profile": This scope enables an app to request profile information from the backend server. The profile 88 | information includes customer's name, email and user_id. 89 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 90 | 91 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 92 | called. The app can now call `getProfile:` to retrieve the user's profile data, or 93 | `getAccessTokenForScopes:withOverrideParams:delegate:` to retrieve the raw access token. On failure, 94 | `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to the method 95 | in the APIError object. Error codes that can be returned by this API are: 96 | 97 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 98 | response from the server. You can allow the user to login again. 99 | - `kAIErrorUserInterrupted` : The user canceled the login page. You can allow the user to login again. 100 | - `kAIAccessDenied` : The user did not consent to the requested scopes. 101 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 102 | Keychain. Calling `clearAuthorizationState:` will help. 103 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 104 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 105 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 106 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 107 | 108 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 109 | "postal_code" is an optional second scope. 110 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 111 | failure messages. 112 | @param options An optional dictionary of options. 113 | @since 1.0 114 | */ 115 | + (void)authorizeUserForScopes:(NSArray *)scopes 116 | delegate:(id )authenticationDelegate 117 | options:(NSDictionary *)options; 118 | 119 | + (void)authorizeUserForScopes:(NSArray *)scopes delegate:(id )authenticationDelegate; 120 | 121 | /** 122 | Once the user has logged in, this method will return a valid access token for the requested scopes. 123 | 124 | This method returns a valid access token, if necessary by exchanging the current refresh token for a new access token. 125 | If the method is successful, this access token is valid for the requested scopes. 126 | 127 | Scopes that can be used with this API are: 128 | 129 | - "profile": This scope enables an app to request profile information from the backend server. The profile 130 | information includes customer's name, email and user_id. 131 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 132 | 133 | Values that can be used in `overrideParams`: 134 | 135 | - `kForceRefresh` - Forces the SDK to refresh the access token, discarding the current one and retrieving a new one. 136 | 137 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 138 | called. The new access token is passed in the result property of the APIResult parameter. The app can then use the 139 | access token directly with services that support it. On failure, `[AIAuthenticationDelegate requestDidFail:]` is 140 | called. The error code and an error message are passed to the method in the APIError object. Error codes that can be 141 | returned by this API are: 142 | 143 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 144 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 145 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 146 | response from the server. You can allow the user to login again. 147 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 148 | Keychain. Calling `clearAuthorizationState:` will help. 149 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 150 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 151 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 152 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 153 | 154 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 155 | "postal_code" is an optional second scope. 156 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 157 | failure messages. 158 | @param overrideParams Dictionary of optional keys to alter behavior of this function. 159 | @since 1.0 160 | */ 161 | + (void)getAccessTokenForScopes:(NSArray *)scopes 162 | withOverrideParams:(NSDictionary *)overrideParams 163 | delegate:(id )authenticationDelegate; 164 | 165 | /** 166 | Deletes cached user tokens and other data. Use this method to logout a user. 167 | 168 | This method removes the authorization tokens from the Keychain. It also clears the cookies from the local cookie 169 | storage to clear the authorization state of the users who checked the "Remember me" checkbox. 170 | 171 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 172 | called. On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are 173 | passed to the method in the APIError object. Error codes that can be returned by this API are: 174 | 175 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 176 | Keychain. 177 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 178 | 179 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 180 | failure messages. 181 | @since 1.0 182 | */ 183 | + (void)clearAuthorizationState:(id )authenticationDelegate; 184 | 185 | /** 186 | Use this method to get the profile of the current authorized user. 187 | 188 | This method gets profile information for the current authorized user. The app should make sure it is authorized for 189 | the "profile" scope prior to calling this method. If the app is authorized for the "postal_code" scope, 190 | getProfile will return that information as well. This profile information is cached for 60 minutes. 191 | 192 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 193 | called. The user profile is passed in the result property of the APIResult parameter as an NSDictionary. The following 194 | keys are used: 195 | 196 | - "name" : The name of the user. 197 | - "email" : The registered email address of the user. 198 | - "user_id" : The used id of the user, in the form of "amzn1.user.VALUE". The user id is unique to the user. 199 | - "postal_code" : The registered postal code of the user. 200 | 201 | On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to 202 | the method in the APIError object. Error codes that can be returned by this API are: 203 | 204 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 205 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 206 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 207 | response from the server. You can allow the user to login again. 208 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 209 | Keychain. Calling `clearAuthorizationState:` will help. 210 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 211 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 212 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 213 | 214 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 215 | failure messages. 216 | @param options An optional dictionary of options. 217 | @since 1.0 218 | */ 219 | + (void)getProfile:(id )authenticationDelegate withOptions:(NSDictionary *)options; 220 | 221 | + (void)getProfile:(id )authenticationDelegate; 222 | 223 | /** 224 | Helper function for `authorizeUserForScopes:delegate:`. 225 | 226 | Call this function from your implementation of the 227 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate. This method handles the 228 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` call from the Safari web browser. The app 229 | should be calling this function when it receives a call to 230 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]`, passing in the `url` and the 231 | `sourceApplication`. If the app fails to do so, the SDK will not be able to complete the login flow. 232 | 233 | The SDK validates the `url` parameter to see if it is valid for the SDK. It is possible the app may want to handle the 234 | `url` as well, in which case the app should first call the SDK to see if this `url` is a callback from Safari and if 235 | the SDK wants to process it. After processing, the SDK will return its preference and the app can then process the 236 | `url` if it chooses. Any error arising from this API is reported through the failure delegate used for the 237 | `authorizeUserForScopes:delegate:` call. 238 | 239 | @param url The url received in the `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate 240 | method. 241 | @param sourceApplication The sourceApplication received in the 242 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate method. 243 | @return Returns YES if the url passed in was a valid url for the SDK and NO if the url was not valid. 244 | @see See `authorizeUserForScopes:delegate:` for more discussion on how to work with this API to complement the login 245 | work flow. 246 | @since 1.0 247 | */ 248 | + (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; 249 | 250 | /** 251 | Helper function for `authorizeUserForScopes:delegate:options:`. 252 | 253 | Use this function to get the clientID encoded in the API key your app uses to configure Login with Amazon SDK 254 | for iOS. This clientId is your client identifier that Login with Amazon SDK uses to authorize customers for your application. 255 | If you are requesting to get an authorization code in return from the `[authorizeUserForScopes:delegate:options:]` 256 | API, you will need this value to call Login with Amazon Authorize Service in exchange for refresh and access tokens. 257 | 258 | @return Return the clientId in need for calling Login with Amazon Authorize Service in exchange for refresh and access tokens. 259 | @since 2.0 260 | */ 261 | 262 | + (NSString *) getClientId; 263 | 264 | /** 265 | Helper function for `authorizeUserForScopes:delegate:options:`. 266 | 267 | Use this function to get the redirect_uri that Login with Amazon SDK uses in the `[authorizeUserForScopes:delegate:options]` 268 | API. If you are requesting to get an authorization code in return, this value is required to call Login with Amazon Authorize 269 | service in exchange for refresh and access tokens. 270 | 271 | @return Return the redirect_uri used in the `[authorizeUserForScopes:delegate:options]` API. 272 | @since 2.0 273 | */ 274 | 275 | + (NSString *) getRedirectUri; 276 | @end 277 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Headers/LoginWithAmazon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIMobileLib.h" 16 | #import "AIAuthenticationDelegate.h" 17 | #import "AIError.h" 18 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/LoginWithAmazon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/LoginWithAmazon.framework/LoginWithAmazon -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/A/Headers/AIAuthenticationDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | @class AIError; 16 | 17 | #pragma mark - API 18 | 19 | /** 20 | These constants identify which API succeeded or failed when calling AIAuthenticationDelegate. The value identifying 21 | the API is passed in the APIResult and APIError objects. 22 | 23 | @since 1.0 24 | */ 25 | typedef NS_ENUM(NSUInteger, API) { 26 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:]` */ 27 | kAPIAuthorizeUser = 1, 28 | /** Refers to `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` */ 29 | kAPIGetAccessToken = 2, 30 | /** Refers to `[AIMobileLib clearAuthorizationState:]` */ 31 | kAPIClearAuthorizationState = 3, 32 | /** Refers to `[AIMobileLib getProfile:]` */ 33 | kAPIGetProfile = 4, 34 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:options]` */ 35 | kAPIGetAuthorizationCode = 5 36 | }; 37 | 38 | #pragma mark - APIResult 39 | /** 40 | This class encapsulates success information from an AIMobileLib API call. 41 | */ 42 | @interface APIResult : NSObject 43 | 44 | - (id)initResultForAPI:(API)anAPI andResult:(id)theResult; 45 | 46 | /** 47 | The result object returned from the API on success. The API result can be `nil`, an `NSDictionary`, or an `NSString` 48 | depending upon which API created the APIResult. 49 | 50 | - `[AIMobileLib authorizeUserForScopes:delegate:]` : Passes `nil` as the result to the delegate. 51 | - `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` : Passes an access token as an `NSString` object 52 | to the delegate. 53 | - `[AIMobileLib clearAuthorizationState:]` : Passes nil as the result to the delegate. 54 | - `[AIMobileLib getProfile:]` : Passes profile data in an `NSDictionary` object to the delegate. See the API description 55 | for information on the key:value pairs expected in profile dictionary. 56 | 57 | @since 1.0 58 | */ 59 | @property (retain) id result; 60 | 61 | /** 62 | The API returning the result. 63 | 64 | @since 1.0 65 | */ 66 | @property API api; 67 | 68 | @end 69 | 70 | #pragma mark - APIError 71 | 72 | /** 73 | This class encapsulates the failure result from an AIMobileLib API call. 74 | */ 75 | @interface APIError : NSObject 76 | 77 | - (id)initErrorForAPI:(API)anAPI andError:(id)theErrorObject; 78 | 79 | /** 80 | The error object returned from the API on failure. 81 | 82 | @see See AIError for more details. 83 | 84 | @since 1.0 85 | */ 86 | @property (retain) AIError *error; 87 | 88 | /** 89 | The API which is returning the error. 90 | 91 | @since 1.0 92 | */ 93 | @property API api; 94 | 95 | @end 96 | 97 | #pragma mark - AIAuthenticationDelegate 98 | /** 99 | Applications calling AIMobileLib APIs must implement the methods of this protocol to receive success and failure 100 | information. 101 | */ 102 | @protocol AIAuthenticationDelegate 103 | 104 | @required 105 | 106 | /** 107 | The APIs call this delegate method with the result when it completes successfully. 108 | 109 | @param apiResult An APIResult object containing the information about the calling API and the result generated. 110 | @see See APIResult for more information on the content of the apiResult. 111 | @since 1.0 112 | */ 113 | - (void)requestDidSucceed:(APIResult *)apiResult; 114 | 115 | 116 | /** 117 | The APIs call this delegate method with the result when it fails. 118 | 119 | @param errorResponse An APIResult object containing the information about the API and the error that occurred. 120 | @see See APIError for more information on the content of the result. 121 | @since 1.0 122 | */ 123 | - (void)requestDidFail:(APIError *)errorResponse; 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/A/Headers/AIError.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #pragma mark - Error codes 16 | 17 | /** 18 | No error, initial value. 19 | */ 20 | extern const NSUInteger kAINoError; 21 | 22 | /** 23 | A valid refresh token was not found. 24 | 25 | The refresh token stored in the SDK is invalid, expired, revoked, does not match 26 | the redirection URI used in the authorization request, does not have the required scopes, or was issued to another 27 | client. `[AIMobileLib getProfile:]` and `[getAccessTokenForScopes:withOverrideParams:delegate:]` can return this 28 | error. 29 | 30 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to request 31 | authorization, or call `[AIMobileLib clearAuthorizationState:]` to logout the user. 32 | */ 33 | extern const NSUInteger kAIApplicationNotAuthorized; 34 | 35 | /** 36 | An error occurred on the server. 37 | 38 | The server encountered an error while completing the request, or the SDK received an unknown response from the server. 39 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 40 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 41 | 42 | Generally with this type of error, the app can allow the user to retry the last action. 43 | */ 44 | extern const NSUInteger kAIServerError; 45 | 46 | /** 47 | The user canceled the login page. 48 | 49 | The user pressed cancel while on the login or the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 50 | return this error. 51 | 52 | Generally with this type of error, the app can allow the user to login again. 53 | */ 54 | extern const NSUInteger kAIErrorUserInterrupted; 55 | 56 | /** 57 | The resource owner or authorization server denied the request. 58 | 59 | The user declined to authorize the app on the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 60 | return this error. 61 | 62 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to 63 | request authorization. 64 | */ 65 | extern const NSUInteger kAIAccessDenied; 66 | 67 | /** 68 | The SDK encountered an error on the device. 69 | 70 | The SDK returns this when there is a problem with the Keychain. `[AIMobileLib getProfile:]`, 71 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 72 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 73 | 74 | Generally with this type of error, the app can call `[AIMobileLib clearAuthorizationState:]` to reset the Keychain. 75 | */ 76 | extern const NSUInteger kAIDeviceError; 77 | 78 | /** 79 | One of the API parameters is invalid. 80 | 81 | The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, 82 | or is otherwise malformed. 83 | 84 | Check your method parameters and try again. All APIs can return this error. 85 | */ 86 | extern const NSUInteger kAIInvalidInput; 87 | 88 | /** 89 | A network error occurred, possibly due to the user being offline. 90 | 91 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 92 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 93 | 94 | Generally with this type of error, the app can ask the user to check their network connections. 95 | */ 96 | extern const NSUInteger kAINetworkError; 97 | 98 | /** 99 | The client is not authorized to request an authorization code using this method. 100 | 101 | The app is not authorized to make this call. Make sure the registered Bundle identifier matches your app, and that you 102 | have a valid APIKey property in the app property list. 103 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 104 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 105 | */ 106 | extern const NSUInteger kAIUnauthorizedClient; 107 | 108 | /** 109 | An internal error occurred in the SDK. 110 | 111 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 112 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 113 | 114 | Generally these errors cannot be handled by app. Please contact us to report recurring internal errors. 115 | */ 116 | extern const NSUInteger kAIInternalError; 117 | 118 | /** 119 | An version error occurred while the SDK version is not supported for LWA SSO. 120 | Only `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 121 | */ 122 | extern const NSUInteger kAIVersionDenied; 123 | 124 | #pragma mark - AIError 125 | 126 | /** 127 | This class encapsulates the error information generated by the SDK. An AIError object includes the error code and a 128 | meaningful error message. The error code constants are available in the header file. 129 | */ 130 | @interface AIError : NSObject 131 | 132 | /** 133 | The error code for the error encountered by the API. 134 | 135 | @since 1.0 136 | */ 137 | @property NSUInteger code; 138 | 139 | /** 140 | The readable message corresponding to the error code. 141 | 142 | @since 1.0 143 | */ 144 | @property (retain) NSString *message; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/A/Headers/AIMobileLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIError.h" 16 | #import "AIAuthenticationDelegate.h" 17 | 18 | /** 19 | Key name for defining whether to force a refresh of the access token. 20 | 21 | Pass this key with a string value of "YES" to `getAccessTokenForScopes:withOverrideParams:delegate:` to force the 22 | method to refresh the access token. 23 | */ 24 | extern const NSString *kForceRefresh; 25 | 26 | /** 27 | Key name for defining whether sandbox mode is on. 28 | 29 | Pass this key with a string value of "YES" to `authorizeUserForScopes:delegate:options:` to switch to the sandbox mode. 30 | */ 31 | extern const NSString *kAIOptionSandboxMode; 32 | 33 | /** 34 | Key name for defining the scope data parameter. 35 | 36 | Pass this key with a Json encoded string of scope data to`authorizeUserForScopes:delegate:options` as required by certain 37 | types of Amazon services. 38 | */ 39 | extern const NSString *kAIOptionScopeData; 40 | 41 | /** 42 | Key name for defining whether to return authorization code. 43 | 44 | Pass this key with a BOOL value of `YES` to `authorizeUserForScopes:delegate:options` to get back an authorization code. 45 | */ 46 | extern const NSString *kAIOptionReturnAuthCode; 47 | 48 | /** 49 | Key name for defining the SPOP code challenge parameter. 50 | 51 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 52 | with kAIOptionReturnAuthCode as `YES`. 53 | */ 54 | extern const NSString *kAIOptionCodeChallenge; 55 | 56 | /** 57 | Key name for defining the SPOP code challenge method parameter. (Optional) 58 | 59 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 60 | with kAIOptionReturnAuthCode as `YES`. 61 | */ 62 | extern const NSString *kAIOptionCodeChallengeMethod; 63 | 64 | /** 65 | AIMobileLib is a static class that contains Login with Amazon APIs. 66 | 67 | This class provides APIs for getting authorization from users, getting profile information, clearing authorization 68 | state, and getting authorization tokens to access secure data. 69 | */ 70 | @interface AIMobileLib : NSObject 71 | 72 | /** 73 | Allows the user to login and, if necessary, authorize the app for the requested scopes. 74 | 75 | Use this method to request authorization from the user for the required scopes. If the user has not logged in, they 76 | will see a login page. Afterward, if they have not previously approved these scopes for your app, they will see a 77 | consent page. 78 | 79 | The sign-in page is displayed in Safari, so there will be a visible switch from the app to Safari. After the user 80 | signs in on the browser, they are redirected back to the app. The app must define 81 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` in the app delegate and call the 82 | `handleOpenURL:sourceApplication:` API from that delegate method. This allows the SDK to get the login information 83 | from the Safari web browser. 84 | 85 | Scopes that can be used with this API are: 86 | 87 | - "profile": This scope enables an app to request profile information from the backend server. The profile 88 | information includes customer's name, email and user_id. 89 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 90 | 91 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 92 | called. The app can now call `getProfile:` to retrieve the user's profile data, or 93 | `getAccessTokenForScopes:withOverrideParams:delegate:` to retrieve the raw access token. On failure, 94 | `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to the method 95 | in the APIError object. Error codes that can be returned by this API are: 96 | 97 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 98 | response from the server. You can allow the user to login again. 99 | - `kAIErrorUserInterrupted` : The user canceled the login page. You can allow the user to login again. 100 | - `kAIAccessDenied` : The user did not consent to the requested scopes. 101 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 102 | Keychain. Calling `clearAuthorizationState:` will help. 103 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 104 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 105 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 106 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 107 | 108 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 109 | "postal_code" is an optional second scope. 110 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 111 | failure messages. 112 | @param options An optional dictionary of options. 113 | @since 1.0 114 | */ 115 | + (void)authorizeUserForScopes:(NSArray *)scopes 116 | delegate:(id )authenticationDelegate 117 | options:(NSDictionary *)options; 118 | 119 | + (void)authorizeUserForScopes:(NSArray *)scopes delegate:(id )authenticationDelegate; 120 | 121 | /** 122 | Once the user has logged in, this method will return a valid access token for the requested scopes. 123 | 124 | This method returns a valid access token, if necessary by exchanging the current refresh token for a new access token. 125 | If the method is successful, this access token is valid for the requested scopes. 126 | 127 | Scopes that can be used with this API are: 128 | 129 | - "profile": This scope enables an app to request profile information from the backend server. The profile 130 | information includes customer's name, email and user_id. 131 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 132 | 133 | Values that can be used in `overrideParams`: 134 | 135 | - `kForceRefresh` - Forces the SDK to refresh the access token, discarding the current one and retrieving a new one. 136 | 137 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 138 | called. The new access token is passed in the result property of the APIResult parameter. The app can then use the 139 | access token directly with services that support it. On failure, `[AIAuthenticationDelegate requestDidFail:]` is 140 | called. The error code and an error message are passed to the method in the APIError object. Error codes that can be 141 | returned by this API are: 142 | 143 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 144 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 145 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 146 | response from the server. You can allow the user to login again. 147 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 148 | Keychain. Calling `clearAuthorizationState:` will help. 149 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 150 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 151 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 152 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 153 | 154 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 155 | "postal_code" is an optional second scope. 156 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 157 | failure messages. 158 | @param overrideParams Dictionary of optional keys to alter behavior of this function. 159 | @since 1.0 160 | */ 161 | + (void)getAccessTokenForScopes:(NSArray *)scopes 162 | withOverrideParams:(NSDictionary *)overrideParams 163 | delegate:(id )authenticationDelegate; 164 | 165 | /** 166 | Deletes cached user tokens and other data. Use this method to logout a user. 167 | 168 | This method removes the authorization tokens from the Keychain. It also clears the cookies from the local cookie 169 | storage to clear the authorization state of the users who checked the "Remember me" checkbox. 170 | 171 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 172 | called. On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are 173 | passed to the method in the APIError object. Error codes that can be returned by this API are: 174 | 175 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 176 | Keychain. 177 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 178 | 179 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 180 | failure messages. 181 | @since 1.0 182 | */ 183 | + (void)clearAuthorizationState:(id )authenticationDelegate; 184 | 185 | /** 186 | Use this method to get the profile of the current authorized user. 187 | 188 | This method gets profile information for the current authorized user. The app should make sure it is authorized for 189 | the "profile" scope prior to calling this method. If the app is authorized for the "postal_code" scope, 190 | getProfile will return that information as well. This profile information is cached for 60 minutes. 191 | 192 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 193 | called. The user profile is passed in the result property of the APIResult parameter as an NSDictionary. The following 194 | keys are used: 195 | 196 | - "name" : The name of the user. 197 | - "email" : The registered email address of the user. 198 | - "user_id" : The used id of the user, in the form of "amzn1.user.VALUE". The user id is unique to the user. 199 | - "postal_code" : The registered postal code of the user. 200 | 201 | On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to 202 | the method in the APIError object. Error codes that can be returned by this API are: 203 | 204 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 205 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 206 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 207 | response from the server. You can allow the user to login again. 208 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 209 | Keychain. Calling `clearAuthorizationState:` will help. 210 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 211 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 212 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 213 | 214 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 215 | failure messages. 216 | @param options An optional dictionary of options. 217 | @since 1.0 218 | */ 219 | + (void)getProfile:(id )authenticationDelegate withOptions:(NSDictionary *)options; 220 | 221 | + (void)getProfile:(id )authenticationDelegate; 222 | 223 | /** 224 | Helper function for `authorizeUserForScopes:delegate:`. 225 | 226 | Call this function from your implementation of the 227 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate. This method handles the 228 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` call from the Safari web browser. The app 229 | should be calling this function when it receives a call to 230 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]`, passing in the `url` and the 231 | `sourceApplication`. If the app fails to do so, the SDK will not be able to complete the login flow. 232 | 233 | The SDK validates the `url` parameter to see if it is valid for the SDK. It is possible the app may want to handle the 234 | `url` as well, in which case the app should first call the SDK to see if this `url` is a callback from Safari and if 235 | the SDK wants to process it. After processing, the SDK will return its preference and the app can then process the 236 | `url` if it chooses. Any error arising from this API is reported through the failure delegate used for the 237 | `authorizeUserForScopes:delegate:` call. 238 | 239 | @param url The url received in the `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate 240 | method. 241 | @param sourceApplication The sourceApplication received in the 242 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate method. 243 | @return Returns YES if the url passed in was a valid url for the SDK and NO if the url was not valid. 244 | @see See `authorizeUserForScopes:delegate:` for more discussion on how to work with this API to complement the login 245 | work flow. 246 | @since 1.0 247 | */ 248 | + (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; 249 | 250 | /** 251 | Helper function for `authorizeUserForScopes:delegate:options:`. 252 | 253 | Use this function to get the clientID encoded in the API key your app uses to configure Login with Amazon SDK 254 | for iOS. This clientId is your client identifier that Login with Amazon SDK uses to authorize customers for your application. 255 | If you are requesting to get an authorization code in return from the `[authorizeUserForScopes:delegate:options:]` 256 | API, you will need this value to call Login with Amazon Authorize Service in exchange for refresh and access tokens. 257 | 258 | @return Return the clientId in need for calling Login with Amazon Authorize Service in exchange for refresh and access tokens. 259 | @since 2.0 260 | */ 261 | 262 | + (NSString *) getClientId; 263 | 264 | /** 265 | Helper function for `authorizeUserForScopes:delegate:options:`. 266 | 267 | Use this function to get the redirect_uri that Login with Amazon SDK uses in the `[authorizeUserForScopes:delegate:options]` 268 | API. If you are requesting to get an authorization code in return, this value is required to call Login with Amazon Authorize 269 | service in exchange for refresh and access tokens. 270 | 271 | @return Return the redirect_uri used in the `[authorizeUserForScopes:delegate:options]` API. 272 | @since 2.0 273 | */ 274 | 275 | + (NSString *) getRedirectUri; 276 | @end 277 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/A/Headers/LoginWithAmazon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIMobileLib.h" 16 | #import "AIAuthenticationDelegate.h" 17 | #import "AIError.h" 18 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/A/LoginWithAmazon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/LoginWithAmazon.framework/Versions/A/LoginWithAmazon -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/Current/Headers/AIAuthenticationDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | @class AIError; 16 | 17 | #pragma mark - API 18 | 19 | /** 20 | These constants identify which API succeeded or failed when calling AIAuthenticationDelegate. The value identifying 21 | the API is passed in the APIResult and APIError objects. 22 | 23 | @since 1.0 24 | */ 25 | typedef NS_ENUM(NSUInteger, API) { 26 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:]` */ 27 | kAPIAuthorizeUser = 1, 28 | /** Refers to `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` */ 29 | kAPIGetAccessToken = 2, 30 | /** Refers to `[AIMobileLib clearAuthorizationState:]` */ 31 | kAPIClearAuthorizationState = 3, 32 | /** Refers to `[AIMobileLib getProfile:]` */ 33 | kAPIGetProfile = 4, 34 | /** Refers to `[AIMobileLib authorizeUserForScopes:delegate:options]` */ 35 | kAPIGetAuthorizationCode = 5 36 | }; 37 | 38 | #pragma mark - APIResult 39 | /** 40 | This class encapsulates success information from an AIMobileLib API call. 41 | */ 42 | @interface APIResult : NSObject 43 | 44 | - (id)initResultForAPI:(API)anAPI andResult:(id)theResult; 45 | 46 | /** 47 | The result object returned from the API on success. The API result can be `nil`, an `NSDictionary`, or an `NSString` 48 | depending upon which API created the APIResult. 49 | 50 | - `[AIMobileLib authorizeUserForScopes:delegate:]` : Passes `nil` as the result to the delegate. 51 | - `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]` : Passes an access token as an `NSString` object 52 | to the delegate. 53 | - `[AIMobileLib clearAuthorizationState:]` : Passes nil as the result to the delegate. 54 | - `[AIMobileLib getProfile:]` : Passes profile data in an `NSDictionary` object to the delegate. See the API description 55 | for information on the key:value pairs expected in profile dictionary. 56 | 57 | @since 1.0 58 | */ 59 | @property (retain) id result; 60 | 61 | /** 62 | The API returning the result. 63 | 64 | @since 1.0 65 | */ 66 | @property API api; 67 | 68 | @end 69 | 70 | #pragma mark - APIError 71 | 72 | /** 73 | This class encapsulates the failure result from an AIMobileLib API call. 74 | */ 75 | @interface APIError : NSObject 76 | 77 | - (id)initErrorForAPI:(API)anAPI andError:(id)theErrorObject; 78 | 79 | /** 80 | The error object returned from the API on failure. 81 | 82 | @see See AIError for more details. 83 | 84 | @since 1.0 85 | */ 86 | @property (retain) AIError *error; 87 | 88 | /** 89 | The API which is returning the error. 90 | 91 | @since 1.0 92 | */ 93 | @property API api; 94 | 95 | @end 96 | 97 | #pragma mark - AIAuthenticationDelegate 98 | /** 99 | Applications calling AIMobileLib APIs must implement the methods of this protocol to receive success and failure 100 | information. 101 | */ 102 | @protocol AIAuthenticationDelegate 103 | 104 | @required 105 | 106 | /** 107 | The APIs call this delegate method with the result when it completes successfully. 108 | 109 | @param apiResult An APIResult object containing the information about the calling API and the result generated. 110 | @see See APIResult for more information on the content of the apiResult. 111 | @since 1.0 112 | */ 113 | - (void)requestDidSucceed:(APIResult *)apiResult; 114 | 115 | 116 | /** 117 | The APIs call this delegate method with the result when it fails. 118 | 119 | @param errorResponse An APIResult object containing the information about the API and the error that occurred. 120 | @see See APIError for more information on the content of the result. 121 | @since 1.0 122 | */ 123 | - (void)requestDidFail:(APIError *)errorResponse; 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/Current/Headers/AIError.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #pragma mark - Error codes 16 | 17 | /** 18 | No error, initial value. 19 | */ 20 | extern const NSUInteger kAINoError; 21 | 22 | /** 23 | A valid refresh token was not found. 24 | 25 | The refresh token stored in the SDK is invalid, expired, revoked, does not match 26 | the redirection URI used in the authorization request, does not have the required scopes, or was issued to another 27 | client. `[AIMobileLib getProfile:]` and `[getAccessTokenForScopes:withOverrideParams:delegate:]` can return this 28 | error. 29 | 30 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to request 31 | authorization, or call `[AIMobileLib clearAuthorizationState:]` to logout the user. 32 | */ 33 | extern const NSUInteger kAIApplicationNotAuthorized; 34 | 35 | /** 36 | An error occurred on the server. 37 | 38 | The server encountered an error while completing the request, or the SDK received an unknown response from the server. 39 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 40 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 41 | 42 | Generally with this type of error, the app can allow the user to retry the last action. 43 | */ 44 | extern const NSUInteger kAIServerError; 45 | 46 | /** 47 | The user canceled the login page. 48 | 49 | The user pressed cancel while on the login or the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 50 | return this error. 51 | 52 | Generally with this type of error, the app can allow the user to login again. 53 | */ 54 | extern const NSUInteger kAIErrorUserInterrupted; 55 | 56 | /** 57 | The resource owner or authorization server denied the request. 58 | 59 | The user declined to authorize the app on the consent page. `[AIMobileLib authorizeUserForScopes:delegate:]` can 60 | return this error. 61 | 62 | Generally with this type of error, the app can call `[AIMobileLib authorizeUserForScopes:delegate:]` to 63 | request authorization. 64 | */ 65 | extern const NSUInteger kAIAccessDenied; 66 | 67 | /** 68 | The SDK encountered an error on the device. 69 | 70 | The SDK returns this when there is a problem with the Keychain. `[AIMobileLib getProfile:]`, 71 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 72 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 73 | 74 | Generally with this type of error, the app can call `[AIMobileLib clearAuthorizationState:]` to reset the Keychain. 75 | */ 76 | extern const NSUInteger kAIDeviceError; 77 | 78 | /** 79 | One of the API parameters is invalid. 80 | 81 | The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, 82 | or is otherwise malformed. 83 | 84 | Check your method parameters and try again. All APIs can return this error. 85 | */ 86 | extern const NSUInteger kAIInvalidInput; 87 | 88 | /** 89 | A network error occurred, possibly due to the user being offline. 90 | 91 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 92 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 93 | 94 | Generally with this type of error, the app can ask the user to check their network connections. 95 | */ 96 | extern const NSUInteger kAINetworkError; 97 | 98 | /** 99 | The client is not authorized to request an authorization code using this method. 100 | 101 | The app is not authorized to make this call. Make sure the registered Bundle identifier matches your app, and that you 102 | have a valid APIKey property in the app property list. 103 | `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 104 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 105 | */ 106 | extern const NSUInteger kAIUnauthorizedClient; 107 | 108 | /** 109 | An internal error occurred in the SDK. 110 | 111 | `[AIMobileLib getProfile:]`, `[AIMobileLib getAccessTokenForScopes:withOverrideParams:delegate:]`, and 112 | `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 113 | 114 | Generally these errors cannot be handled by app. Please contact us to report recurring internal errors. 115 | */ 116 | extern const NSUInteger kAIInternalError; 117 | 118 | /** 119 | An version error occurred while the SDK version is not supported for LWA SSO. 120 | Only `[AIMobileLib authorizeUserForScopes:delegate:]` can return this error. 121 | */ 122 | extern const NSUInteger kAIVersionDenied; 123 | 124 | #pragma mark - AIError 125 | 126 | /** 127 | This class encapsulates the error information generated by the SDK. An AIError object includes the error code and a 128 | meaningful error message. The error code constants are available in the header file. 129 | */ 130 | @interface AIError : NSObject 131 | 132 | /** 133 | The error code for the error encountered by the API. 134 | 135 | @since 1.0 136 | */ 137 | @property NSUInteger code; 138 | 139 | /** 140 | The readable message corresponding to the error code. 141 | 142 | @since 1.0 143 | */ 144 | @property (retain) NSString *message; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/Current/Headers/AIMobileLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIError.h" 16 | #import "AIAuthenticationDelegate.h" 17 | 18 | /** 19 | Key name for defining whether to force a refresh of the access token. 20 | 21 | Pass this key with a string value of "YES" to `getAccessTokenForScopes:withOverrideParams:delegate:` to force the 22 | method to refresh the access token. 23 | */ 24 | extern const NSString *kForceRefresh; 25 | 26 | /** 27 | Key name for defining whether sandbox mode is on. 28 | 29 | Pass this key with a string value of "YES" to `authorizeUserForScopes:delegate:options:` to switch to the sandbox mode. 30 | */ 31 | extern const NSString *kAIOptionSandboxMode; 32 | 33 | /** 34 | Key name for defining the scope data parameter. 35 | 36 | Pass this key with a Json encoded string of scope data to`authorizeUserForScopes:delegate:options` as required by certain 37 | types of Amazon services. 38 | */ 39 | extern const NSString *kAIOptionScopeData; 40 | 41 | /** 42 | Key name for defining whether to return authorization code. 43 | 44 | Pass this key with a BOOL value of `YES` to `authorizeUserForScopes:delegate:options` to get back an authorization code. 45 | */ 46 | extern const NSString *kAIOptionReturnAuthCode; 47 | 48 | /** 49 | Key name for defining the SPOP code challenge parameter. 50 | 51 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 52 | with kAIOptionReturnAuthCode as `YES`. 53 | */ 54 | extern const NSString *kAIOptionCodeChallenge; 55 | 56 | /** 57 | Key name for defining the SPOP code challenge method parameter. (Optional) 58 | 59 | Pass this key with a string value into the `options` object used when calling `authorizeUserForScopes:delegate:options` 60 | with kAIOptionReturnAuthCode as `YES`. 61 | */ 62 | extern const NSString *kAIOptionCodeChallengeMethod; 63 | 64 | /** 65 | AIMobileLib is a static class that contains Login with Amazon APIs. 66 | 67 | This class provides APIs for getting authorization from users, getting profile information, clearing authorization 68 | state, and getting authorization tokens to access secure data. 69 | */ 70 | @interface AIMobileLib : NSObject 71 | 72 | /** 73 | Allows the user to login and, if necessary, authorize the app for the requested scopes. 74 | 75 | Use this method to request authorization from the user for the required scopes. If the user has not logged in, they 76 | will see a login page. Afterward, if they have not previously approved these scopes for your app, they will see a 77 | consent page. 78 | 79 | The sign-in page is displayed in Safari, so there will be a visible switch from the app to Safari. After the user 80 | signs in on the browser, they are redirected back to the app. The app must define 81 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` in the app delegate and call the 82 | `handleOpenURL:sourceApplication:` API from that delegate method. This allows the SDK to get the login information 83 | from the Safari web browser. 84 | 85 | Scopes that can be used with this API are: 86 | 87 | - "profile": This scope enables an app to request profile information from the backend server. The profile 88 | information includes customer's name, email and user_id. 89 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 90 | 91 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 92 | called. The app can now call `getProfile:` to retrieve the user's profile data, or 93 | `getAccessTokenForScopes:withOverrideParams:delegate:` to retrieve the raw access token. On failure, 94 | `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to the method 95 | in the APIError object. Error codes that can be returned by this API are: 96 | 97 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 98 | response from the server. You can allow the user to login again. 99 | - `kAIErrorUserInterrupted` : The user canceled the login page. You can allow the user to login again. 100 | - `kAIAccessDenied` : The user did not consent to the requested scopes. 101 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 102 | Keychain. Calling `clearAuthorizationState:` will help. 103 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 104 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 105 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 106 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 107 | 108 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 109 | "postal_code" is an optional second scope. 110 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 111 | failure messages. 112 | @param options An optional dictionary of options. 113 | @since 1.0 114 | */ 115 | + (void)authorizeUserForScopes:(NSArray *)scopes 116 | delegate:(id )authenticationDelegate 117 | options:(NSDictionary *)options; 118 | 119 | + (void)authorizeUserForScopes:(NSArray *)scopes delegate:(id )authenticationDelegate; 120 | 121 | /** 122 | Once the user has logged in, this method will return a valid access token for the requested scopes. 123 | 124 | This method returns a valid access token, if necessary by exchanging the current refresh token for a new access token. 125 | If the method is successful, this access token is valid for the requested scopes. 126 | 127 | Scopes that can be used with this API are: 128 | 129 | - "profile": This scope enables an app to request profile information from the backend server. The profile 130 | information includes customer's name, email and user_id. 131 | - "postal_code": This scope enables an app to request the postal code registered to the user's account. 132 | 133 | Values that can be used in `overrideParams`: 134 | 135 | - `kForceRefresh` - Forces the SDK to refresh the access token, discarding the current one and retrieving a new one. 136 | 137 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 138 | called. The new access token is passed in the result property of the APIResult parameter. The app can then use the 139 | access token directly with services that support it. On failure, `[AIAuthenticationDelegate requestDidFail:]` is 140 | called. The error code and an error message are passed to the method in the APIError object. Error codes that can be 141 | returned by this API are: 142 | 143 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 144 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 145 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 146 | response from the server. You can allow the user to login again. 147 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 148 | Keychain. Calling `clearAuthorizationState:` will help. 149 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 150 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 151 | - `kAIUnauthorizedClient` : The app is not authorized to make this call. 152 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 153 | 154 | @param scopes The profile scopes that the app is requesting from the user. The first scope must be "profile". 155 | "postal_code" is an optional second scope. 156 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 157 | failure messages. 158 | @param overrideParams Dictionary of optional keys to alter behavior of this function. 159 | @since 1.0 160 | */ 161 | + (void)getAccessTokenForScopes:(NSArray *)scopes 162 | withOverrideParams:(NSDictionary *)overrideParams 163 | delegate:(id )authenticationDelegate; 164 | 165 | /** 166 | Deletes cached user tokens and other data. Use this method to logout a user. 167 | 168 | This method removes the authorization tokens from the Keychain. It also clears the cookies from the local cookie 169 | storage to clear the authorization state of the users who checked the "Remember me" checkbox. 170 | 171 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 172 | called. On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are 173 | passed to the method in the APIError object. Error codes that can be returned by this API are: 174 | 175 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 176 | Keychain. 177 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 178 | 179 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 180 | failure messages. 181 | @since 1.0 182 | */ 183 | + (void)clearAuthorizationState:(id )authenticationDelegate; 184 | 185 | /** 186 | Use this method to get the profile of the current authorized user. 187 | 188 | This method gets profile information for the current authorized user. The app should make sure it is authorized for 189 | the "profile" scope prior to calling this method. If the app is authorized for the "postal_code" scope, 190 | getProfile will return that information as well. This profile information is cached for 60 minutes. 191 | 192 | The result of this API is sent to the `delegate`. On success, `[AIAuthenticationDelegate requestDidSucceed:]` is 193 | called. The user profile is passed in the result property of the APIResult parameter as an NSDictionary. The following 194 | keys are used: 195 | 196 | - "name" : The name of the user. 197 | - "email" : The registered email address of the user. 198 | - "user_id" : The used id of the user, in the form of "amzn1.user.VALUE". The user id is unique to the user. 199 | - "postal_code" : The registered postal code of the user. 200 | 201 | On failure, `[AIAuthenticationDelegate requestDidFail:]` is called. The error code and an error message are passed to 202 | the method in the APIError object. Error codes that can be returned by this API are: 203 | 204 | - `kAIApplicationNotAuthorized` : The app is not authorized for scopes requested. Call 205 | `authorizeUserForScopes:delegate:` to allow the user to authorize the app. 206 | - `kAIServerError` : The server encountered an error while completing the request, or the SDK received an unknown 207 | response from the server. You can allow the user to login again. 208 | - `kAIDeviceError` : The SDK encountered an error on the device. The SDK returns this when there is a problem with the 209 | Keychain. Calling `clearAuthorizationState:` will help. 210 | - `kAIInvalidInput` : One of the API parameters is invalid. See the error message for more information. 211 | - `kAINetworkError` : A network error occurred, possibly due to the user being offline. 212 | - `kAIInternalError` : An internal error occurred in the SDK. You can allow the user to login again. 213 | 214 | @param authenticationDelegate A delegate implementing the `AIAuthenticationDelegate` protocol to receive success and 215 | failure messages. 216 | @param options An optional dictionary of options. 217 | @since 1.0 218 | */ 219 | + (void)getProfile:(id )authenticationDelegate withOptions:(NSDictionary *)options; 220 | 221 | + (void)getProfile:(id )authenticationDelegate; 222 | 223 | /** 224 | Helper function for `authorizeUserForScopes:delegate:`. 225 | 226 | Call this function from your implementation of the 227 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate. This method handles the 228 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` call from the Safari web browser. The app 229 | should be calling this function when it receives a call to 230 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]`, passing in the `url` and the 231 | `sourceApplication`. If the app fails to do so, the SDK will not be able to complete the login flow. 232 | 233 | The SDK validates the `url` parameter to see if it is valid for the SDK. It is possible the app may want to handle the 234 | `url` as well, in which case the app should first call the SDK to see if this `url` is a callback from Safari and if 235 | the SDK wants to process it. After processing, the SDK will return its preference and the app can then process the 236 | `url` if it chooses. Any error arising from this API is reported through the failure delegate used for the 237 | `authorizeUserForScopes:delegate:` call. 238 | 239 | @param url The url received in the `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate 240 | method. 241 | @param sourceApplication The sourceApplication received in the 242 | `[UIApplicationDelegate application:openURL:sourceApplication:annotation]` delegate method. 243 | @return Returns YES if the url passed in was a valid url for the SDK and NO if the url was not valid. 244 | @see See `authorizeUserForScopes:delegate:` for more discussion on how to work with this API to complement the login 245 | work flow. 246 | @since 1.0 247 | */ 248 | + (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; 249 | 250 | /** 251 | Helper function for `authorizeUserForScopes:delegate:options:`. 252 | 253 | Use this function to get the clientID encoded in the API key your app uses to configure Login with Amazon SDK 254 | for iOS. This clientId is your client identifier that Login with Amazon SDK uses to authorize customers for your application. 255 | If you are requesting to get an authorization code in return from the `[authorizeUserForScopes:delegate:options:]` 256 | API, you will need this value to call Login with Amazon Authorize Service in exchange for refresh and access tokens. 257 | 258 | @return Return the clientId in need for calling Login with Amazon Authorize Service in exchange for refresh and access tokens. 259 | @since 2.0 260 | */ 261 | 262 | + (NSString *) getClientId; 263 | 264 | /** 265 | Helper function for `authorizeUserForScopes:delegate:options:`. 266 | 267 | Use this function to get the redirect_uri that Login with Amazon SDK uses in the `[authorizeUserForScopes:delegate:options]` 268 | API. If you are requesting to get an authorization code in return, this value is required to call Login with Amazon Authorize 269 | service in exchange for refresh and access tokens. 270 | 271 | @return Return the redirect_uri used in the `[authorizeUserForScopes:delegate:options]` API. 272 | @since 2.0 273 | */ 274 | 275 | + (NSString *) getRedirectUri; 276 | @end 277 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/Current/Headers/LoginWithAmazon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy 5 | * of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 10 | * KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 | */ 12 | 13 | #import 14 | 15 | #import "AIMobileLib.h" 16 | #import "AIAuthenticationDelegate.h" 17 | #import "AIError.h" 18 | -------------------------------------------------------------------------------- /iOS Alexa/LoginWithAmazon.framework/Versions/Current/LoginWithAmazon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintan1891/iOS-Alexa/05ba5cd490d589f509d6bd5363d11070960bc498/iOS Alexa/LoginWithAmazon.framework/Versions/Current/LoginWithAmazon -------------------------------------------------------------------------------- /iOS Alexa/ViewController/HomeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HomeViewController.swift 3 | // iOS Alexa 4 | // 5 | // Created by Chintan Prajapati on 23/05/16. 6 | // Copyright © 2016 Chintan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | 12 | class HomeViewController: UIViewController, AVAudioPlayerDelegate { 13 | 14 | @IBOutlet var recordButton: UIButton! 15 | @IBOutlet var statusLabel: UILabel! 16 | 17 | private var isRecording = false 18 | 19 | private var simplePCMRecorder: SimplePCMRecorder 20 | 21 | private let tempFilename = "\(NSTemporaryDirectory())avsexample.wav" 22 | 23 | private var player: AVAudioPlayer? 24 | 25 | required init?(coder: NSCoder) { 26 | self.simplePCMRecorder = SimplePCMRecorder(numberBuffers: 1) 27 | 28 | super.init(coder: coder) 29 | } 30 | 31 | override func viewDidLoad() { 32 | super.viewDidLoad() 33 | 34 | // Do any additional setup after loading the view. 35 | 36 | // Have the recorder create a first recording that will get tossed so it starts faster later 37 | do { 38 | try self.simplePCMRecorder.setupForRecording(tempFilename, sampleRate:16000, channels:1, bitsPerChannel:16, errorHandler: nil) 39 | try self.simplePCMRecorder.startRecording() 40 | try self.simplePCMRecorder.stopRecording() 41 | self.simplePCMRecorder = SimplePCMRecorder(numberBuffers: 1) 42 | } catch _ { 43 | //CRToastManager.showNotificationWithMessage("Something went wrong during Microphone initialization", completionBlock: nil) 44 | } 45 | } 46 | 47 | @IBAction func recordAction(sender: AnyObject) { 48 | if !self.isRecording { 49 | do { 50 | self.isRecording = true 51 | 52 | self.simplePCMRecorder = SimplePCMRecorder(numberBuffers: 1) 53 | try! self.simplePCMRecorder.setupForRecording(tempFilename, sampleRate:16000, channels:1, bitsPerChannel:16, errorHandler: { (error:NSError) -> Void in 54 | print(error) 55 | try! self.simplePCMRecorder.stopRecording() 56 | }) 57 | try self.simplePCMRecorder.startRecording() 58 | 59 | self.recordButton.setImage(UIImage(named: "StopIcon"), forState: .Normal) 60 | self.statusLabel.text = "Listening..." 61 | } catch _ { 62 | self.statusLabel.text = "Something went wrong while starting Microphone" 63 | } 64 | } else { 65 | 66 | do { 67 | self.isRecording = false 68 | 69 | self.recordButton.enabled = false 70 | 71 | try self.simplePCMRecorder.stopRecording() 72 | 73 | self.recordButton.setImage(UIImage(named: "MicIcon"), forState: .Normal) 74 | self.statusLabel.text = "Uploading recording" 75 | 76 | self.upload() 77 | } catch _ { 78 | self.statusLabel.text = "Something went wrong while stopping Microphone" 79 | } 80 | } 81 | 82 | } 83 | 84 | private func upload() { 85 | let uploader = AVSUploader() 86 | 87 | uploader.authToken = ISSharedData.sharedInstance.accessToken 88 | 89 | uploader.jsonData = self.createMeatadata() 90 | 91 | uploader.audioData = NSData(contentsOfFile: tempFilename)! 92 | 93 | uploader.errorHandler = { (error:NSError) in 94 | if Config.Debug.Errors { 95 | print("Upload error: \(error)") 96 | } 97 | 98 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 99 | self.statusLabel.text = "Upload error: \(error.localizedDescription)" 100 | self.recordButton.enabled = true 101 | }) 102 | } 103 | 104 | uploader.progressHandler = { (progress:Double) in 105 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 106 | if progress < 100.0 { 107 | self.statusLabel.text = String(format: "Uploading recording") 108 | } else { 109 | self.statusLabel.text = "Waiting for response" 110 | } 111 | }) 112 | } 113 | 114 | uploader.successHandler = { (data:NSData, parts:[PartData]) -> Void in 115 | 116 | for part in parts { 117 | if part.headers["Content-Type"] == "application/json" { 118 | if Config.Debug.General { 119 | print(NSString(data: part.data, encoding: NSUTF8StringEncoding)) 120 | } 121 | } else if part.headers["Content-Type"] == "audio/mpeg" { 122 | do { 123 | self.player = try AVAudioPlayer(data: part.data) 124 | self.player?.delegate = self 125 | self.player?.play() 126 | 127 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 128 | self.statusLabel.text = "Playing response" 129 | }) 130 | } catch let error { 131 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 132 | self.statusLabel.text = "Playing error: \(error)" 133 | self.recordButton.enabled = true 134 | }) 135 | } 136 | } 137 | } 138 | 139 | } 140 | 141 | try! uploader.start() 142 | } 143 | 144 | private func createMeatadata() -> String? { 145 | var rootElement = [String:AnyObject]() 146 | 147 | let deviceContextPayload = ["streamId":"", "offsetInMilliseconds":"0", "playerActivity":"IDLE"] 148 | let deviceContext = ["name":"playbackState", "namespace":"AudioPlayer", "payload":deviceContextPayload] 149 | rootElement["messageHeader"] = ["deviceContext":[deviceContext]] 150 | 151 | let deviceProfile = ["profile":"doppler-scone", "locale":"en-us", "format":"audio/L16; rate=16000; channels=1"] 152 | rootElement["messageBody"] = deviceProfile 153 | 154 | let data = try! NSJSONSerialization.dataWithJSONObject(rootElement, options: NSJSONWritingOptions(rawValue: 0)) 155 | 156 | return NSString(data: data, encoding: NSUTF8StringEncoding) as String? 157 | } 158 | 159 | func audioPlayerDidFinishPlaying(player: AVAudioPlayer, successfully flag: Bool) { 160 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 161 | self.statusLabel.text = "Speak Now" 162 | self.recordButton.enabled = true 163 | }) 164 | } 165 | 166 | func audioPlayerDecodeErrorDidOccur(player: AVAudioPlayer, error: NSError?) { 167 | dispatch_async(dispatch_get_main_queue(), { () -> Void in 168 | self.statusLabel.text = "Player error: \(error)" 169 | self.recordButton.enabled = true 170 | }) 171 | } 172 | 173 | override func didReceiveMemoryWarning() { 174 | super.didReceiveMemoryWarning() 175 | // Dispose of any resources that can be recreated. 176 | } 177 | 178 | @IBAction func logoutClicked(sender: AnyObject) { 179 | AIMobileLib.clearAuthorizationState(nil) 180 | self.dismissViewControllerAnimated(false, completion: nil) 181 | } 182 | 183 | deinit { 184 | NSNotificationCenter.defaultCenter().removeObserver(self) 185 | } 186 | 187 | /* 188 | // MARK: - Navigation 189 | 190 | // In a storyboard-based application, you will often want to do a little preparation before navigation 191 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 192 | // Get the new view controller using segue.destinationViewController. 193 | // Pass the selected object to the new view controller. 194 | } 195 | */ 196 | 197 | } 198 | -------------------------------------------------------------------------------- /iOS Alexa/ViewController/LoginViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LoginViewController.h 3 | // iOS Alexa 4 | // 5 | // Created by Chintan Prajapati on 13/05/16. 6 | // Copyright © 2016 Chintan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LoginViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /iOS Alexa/ViewController/LoginViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // LoginViewController.m 3 | // iOS Alexa 4 | // 5 | // Created by Chintan Prajapati on 13/05/16. 6 | // Copyright © 2016 Chintan. All rights reserved. 7 | // 8 | 9 | #import "LoginViewController.h" 10 | #import 11 | #import "iOS_Alexa-Swift.h" 12 | #import "MBProgressHUD.h" 13 | 14 | #define SCOPE_DATA @"{\"alexa:all\":{\"productID\":\"<< Product ID Here >>\",""\"productInstanceAttributes\":{\"deviceSerialNumber\":\"<< Device Serial Number Here >>\"}}}" 15 | 16 | @interface LoginViewController () 17 | { 18 | BOOL triedExistingAccessToken; 19 | } 20 | 21 | @property (strong, nonatomic) IBOutlet UIButton *loginButton; 22 | @end 23 | 24 | @implementation LoginViewController 25 | 26 | -(void) viewDidLoad { 27 | [super viewDidLoad]; 28 | } 29 | 30 | - (void)viewDidAppear:(BOOL)animated { 31 | [super viewDidAppear:animated]; 32 | 33 | //[AIMobileLib clearAuthorizationState:nil]; 34 | 35 | if (!triedExistingAccessToken) { 36 | [AIMobileLib getAccessTokenForScopes:@[@"alexa:all"] withOverrideParams:nil delegate:self]; 37 | triedExistingAccessToken = true; 38 | } 39 | } 40 | 41 | - (IBAction)loginButtonClicked:(id)sender { 42 | //[MBProgressHUD showHUDAddedTo:self.view animated:true]; 43 | [AIMobileLib authorizeUserForScopes:@[@"alexa:all"] delegate:self options:@{kAIOptionScopeData:SCOPE_DATA}]; 44 | } 45 | 46 | - (void)requestDidSucceed:(APIResult *)apiResult { 47 | 48 | if (apiResult.api == kAPIAuthorizeUser) { 49 | [AIMobileLib getAccessTokenForScopes:@[@"alexa:all"] withOverrideParams:nil delegate:self]; 50 | } 51 | else { 52 | ISSharedData.sharedInstance.accessToken = apiResult.result; 53 | [self performSegueWithIdentifier:@"HomeViewController" sender:nil]; 54 | [MBProgressHUD hideAllHUDsForView:self.view animated:true]; 55 | self.loginButton.hidden = false; 56 | } 57 | } 58 | 59 | - (void)requestDidFail:(APIError *)apiResult { 60 | self.loginButton.hidden = false; 61 | [MBProgressHUD hideAllHUDsForView:self.view animated:true]; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /iOS Alexa/iOS Alexa-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import 6 | #import --------------------------------------------------------------------------------