Pages

Showing posts with label iOS. Show all posts
Showing posts with label iOS. Show all posts

2014/05/07

How to secure connection between AWS SDK and mobile APP(Android, iOS)?

This article shows the steps to build the secure connection between AWS SDK and mobile APP(Android, iOS).

   Using the root key(access key ID, secret access key) in your mobile application in plain text is very dangerous.
AWS has a service for mobile client devices to connect to the AWS. The TVM(Token Vending Machine) creates a temporary credentials for mobile clients.
The IAM(Identity and Access Management) user is a limited grant permissions user for access AWS.
Here we will create a IAM user and build a TVM server for anonymous registration.

Step1:Fallow the steps to create a user to your AWS account for the TVM. Start from the paragraph "To add a user to your AWS account for the TVM" from this link. Token Vending Machine for Anonymous Registration - Sample Java Web Application.

Step2:Create a TVM server. Start from the paragraph "Create the AWS Elastic Beanstalk application" from this link. Token Vending Machine for Anonymous Registration - Sample Java Web Application.

Step3:Now you should have a IAM user and a TVM server runs on your AWS account. Download the AnonymousTVM sample for test. If you using Android download from this link aws-sdk-android-samples. This is for iOS aws-sdk-ios-samples. Fallow the README.md to run the project.


Step4:If you have a existed project using the root key, you can easily change to TVM. Copy the necessary files from the example to your project. These are iOS example files.
remove the Create Certificate codes.
        //Create Certificate
        mCertificate = [[AmazonCredentials alloc] initWithAccessKey:AccessKeyID withSecretKey:SecretAccessKey];
        
        //Initialize DynamoDBClient
        mDdbClient = [[AmazonDynamoDBClient alloc] initWithCredentials:mCertificate];

Change the access code.
From
DynamoDBPutItemResponse *response = [mDdbClient putItem:request];

To
DynamoDBPutItemResponse *response = [[AmazonClientManagerRunway ddb] putItem:request];

And That's it.

2012/12/24

更改 iOS navigationItem.backBarButtonItem.title

iOS navigationItem.backBarButtonItem.title 不能直接改名.
因為它會引用 parent controller 的title, 也就是按下 back button 會返回的controller title.
所以方法1. 將parent controller 的title 改名.
方法2. 產生新的UIBarButtonItem,但是 back button 的外型會變成四方.

2012/11/13

How to use OpenCV in iOS?

This article shows the steps to build the OpenCV application under the iOS.
Step1:Download the pre-compile binary OpenCV library for iOS framework. Refers to the link. Direct download link OpenCV-2.4-build.zip.
Step2:Extract the zip file to the directory, for example, '~/opencv-2.4-build'.
Step3:Open the XCode project to setup the project.Go to the Targets build setting.
Add a Header Search Paths for debug and release with the string "~/opencv-2.4-build/**".
Add a Library Search Paths for debug with the string "~/opencv-2.4-build/lib/debug".
And for release path with string "~/opencv-2.4-build/lib/release".
Step4:Setting linking path to the project.
Add the string "-lopencv_calib3d -lzlib -lopencv_contrib -lopencv_legacy -lopencv_features2d -lopencv_imgproc -lopencv_video -lopencv_core" to the Other Linker flag.
Step5:Modify the project Prefix header.
Add these code to the [YourProjectName]-Prefix.pch file.
#ifdef __cplusplus
    #include <opencv2/opencv.hpp>
    #include <opencv2/nonfree/nonfree.hpp>
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

Step6:Now you can use the OpenCV API.

2012/10/04

How to using Git repository on Dropbox to back up XCode Project?

This article teaches how to using Git repository on Dropbox to back up XCode Project. Step1:Create XCode project and allowed it to set up a local Git Repository. Step2:Open a console and chdir to the XCode project directory.
$cd ~/MyProject/NewProject1

Step3:Clone a git repository to the Dropbox directory. That is the .git directory in the NewProject1.We do not want the whole working code sync with Dropbox.
$git clone --bare . ~/Dropbox/git/repo/NewProject1.git

Step4:Create a remote git repository. XCode will recognize this remote repo.
$git remote add NewProject1 ~/Dropbox/git/repo/NewProject1.git

Step5:Add Git .gitignore file to the project directory.
# .gitignore file for Xcode4 / OS X Source projects
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
# Generated
*.o
*.pyc 


Step6:Now we can use this remote git repository in the XCode.Open the NewProject1 project in the XCode. Go to the menubar, File->Source Control->Push. Now you can find the remote repository.