0
私は実行可能なプッシュアクションを実装しています。私はクリックアクションの後に次のメソッドを取得しています。iOSのhandleActionWithIdentifier:forRemoteNotificationでhttpコールを高速化しますか?
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {
NSError *error;
NSDictionary* jsonDict = [[NSMutableDictionary alloc] init];
[jsonDict setValue:[[jsonArray1 valueForKey:@"uid"] lowercaseString] forKey:@"actionby"];
[jsonDict setValue:@"" forKey:@"alid"];
[jsonDict setValue:strOTP forKey:@"tp"];
[jsonDict setValue:@"1" forKey:@"txf"];
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict
options:NSJSONWritingPrettyPrinted error:&error];
NSString *str = [[NSString alloc] initWithData:jsonData encoding:NSASCIIStringEncoding];
NSString *trimmedTweet = [str stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
NSString *nospaceStr = [trimmedTweet stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *encrypted [email protected]"";
encrypted = [sharedData testSecKey:nospaceStr];
if([encrypted length] > 0) {
encrypted = [NSString stringWithFormat:@"enc{%@}",encrypted];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [SharedData getGatewayURL]]]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:15];
[request setHTTPMethod:@"POST"];
NSString *encodedXML = [encrypted urlEncodeUsingEncoding:NSUTF8StringEncoding];
NSString *params = [NSString stringWithFormat:@"%@=%@", REQUEST_PARAMETER_NAME, encodedXML];
[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
[conn start];
if (completionHandler) {
completionHandler();
}
}
デリゲートメソッドも処理します。バックグラウンドでこの応答は遅すぎる(私は2つのWebサービスを打つ必要があります)?これを修正するには?どのように応答をスピードアップするには?
複合Webサービスを作成します。 – Wain
@Wain。レスポンスありがとう。しかしそれ以上の時間がかかります。まだ応答を得ることはできません。何が問題なの?それはNSURLConnectionでうまくいくのですか? –
できる場合はURLセッションを使用する必要があります – Wain