0
我有一個使用AFHTTPRequestOperationManager
使用下面的代碼來執行登錄應用程序:創建Safari瀏覽器的cookie
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
loginNameField.text, @"username",
loginPasswordField.text, @"password",
uniqueUserToken, @"device_id",
nil];
NSMutableURLRequest* request = [self.operationManager.requestSerializer requestWithMethod:@"POST" URLString:LOGIN_URL parameters:params error:nil];
AFHTTPRequestOperation* operation = [self.operationManager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
//completion block
}
[self.operationManager.operationQueue addOperation:operation];
我想要做的是,一旦用戶登錄,在與應用,請在Safari中創建一個cookie,以便用戶在瀏覽器中直接轉到主站點而不是登錄頁面。
我嘗試使用以下,但仍Safari瀏覽器登陸該網站的登錄頁面:
NSString *myRequestString = [NSString stringWithFormat:@"username=%@&password=%@&device_id=%@", loginNameField.text, loginPasswordField.text, uniqueUserToken];
NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length ]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:LOGIN_URL]];
[request setHTTPMethod: @"POST" ];
[request setHTTPBody:myRequestData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];
現在我明白了應用程序的沙盒中的iOS,因此,這裏的問題。我已閱讀其他問題,但我對javaScript
的瞭解還處於起步階段。任何幫助,將不勝感激。