title: How to implement Amazon Kinesis Streaming to process data in real time in iOS App
body: <p>I have gone through the doc of Amazon web Services (AWS) for Kinesis Streaming (real time data processing). But I am getting confuse about how to implement Kinesis Streaming.</p>
  <ul>
  <li>Installed SDK for iOS in project.</li>
  <li>Written code of Cognito Credentials with region and pool-ID.</li>
  <li>Successfully done with AWSServiceConfiguration.</li>
  <li>In viewcontroller, I have written a code to save data in
  AWSKinesisRecorder Stream.</li>
  </ul>
  <p>But how can I know about data is Successfully saving in Stream? How can I put a print log?</p>
  <p>I want to show Successfully saved data in console.</p>
  <pre><code>AppDelegate Code:
  
  
   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool {
          AWSLogger.default().logLevel = .verbose
          
          let CognitoPoolID = &quot;ap-northeast-1:430840dc-4df5-469f&quot;
          let Region = AWSRegionType.APNortheast1
          let credentialsProvider = AWSCognitoCredentialsProvider(regionType:Region,identityPoolId:CognitoPoolID)
          
          let configuration = AWSServiceConfiguration(region:Region, credentialsProvider:credentialsProvider)
          AWSServiceManager.default().defaultServiceConfiguration = configuration
          
          return true
      }
  </code></pre>
  <p>ViewController code:</p>
  <pre><code>import UIKit 
  import AWSKinesis
  
  class ViewController: UIViewController {
  
         var kinesisRecorder : AWSKinesisRecorder! = nil
  
         override func viewDidLoad() {
            super.viewDidLoad()
      
          //use AWSKinesisRecorder with Amazon Kinesis. The following snippet returns a shared instance of the Amazon Kinesis service client
           kinesisRecorder = AWSKinesisRecorder.default()
      
      
            configureAWSKinesisRecorder()
          saveDataInStream()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      /*
       * Method to configure perties of AWSKinesisRecorder
       */
      func configureAWSKinesisRecorder()  {
          //The diskAgeLimit property sets the expiration for cached requests. When a request exceeds the limit, it's discarded. The default is no age limit.
  
          kinesisRecorder.diskAgeLimit = TimeInterval(30 * 24 * 60 * 60); // 30 days
      
      
          //The diskByteLimit property holds the limit of the disk cache size in bytes. If the storage limit is exceeded, older requests are discarded. The default value is 5 MB. Setting the value to 0 means that there's no practical limit.
  
          kinesisRecorder.diskByteLimit = UInt(10 * 1024 * 1024); // 10MB
      
      
          //The notficationByteThreshold property sets the point beyond which Kinesis issues a notification that the byte threshold has been reached. The default value is 0, meaning that by default Amazon Kinesis doesn't post the notification.
  
          kinesisRecorder.notificationByteThreshold = UInt(5 * 1024 * 1024); // 5MB
      
      }
  
      /*
       * Method to save real time data in AWS stream
       */
      func saveDataInStream()  {
     
      
          //Both saveRecord and submitAllRecords are asynchronous operations, so you should ensure that saveRecord is complete before you invoke submitAllRecords.
      
          // Create an array to store a batch of objects.
          var tasks = Array&lt;AWSTask&lt;AnyObject&gt;&gt;()
          for i in 0...5 {
              //create an NSData object .
              //StreamName should be a string corresponding to the name of your Kinesis stream.
              //save it locally in kinesisRecorder instances
  
              tasks.append(kinesisRecorder!.saveRecord(String(format: &quot;TestString-%02d&quot;, i).data(using: .utf8), streamName: &quot;my_stream&quot;)!)
          }
      
          ////submitAllRecords sends all locally saved requests to the Amazon Kinesis service.
          AWSTask(forCompletionOfAllTasks: tasks).continueOnSuccessWith(block: { (task:AWSTask&lt;AnyObject&gt;) -&gt; AWSTask&lt;AnyObject&gt;? in
              return self.kinesisRecorder?.submitAllRecords()
          }).continueWith(block: { (task:AWSTask&lt;AnyObject&gt;) -&gt; Any? in
              if let error = task.error as? NSError {
                  print(&quot;Error: \(error)&quot;)
              }
              return nil
          }
      
          )
      
      
      
      } 
  }
  </code></pre>