0

このリンクをたどっ てアクセス トークンを取得していますが、以下のコード、特に URL とコンテンツでリークが発生しています。

 -(void)connectionDidFinishLoading:(NSURLConnection *)connection

 {

  if(_data)
  {
    NSString* content = [[NSString alloc] initWithData:_data
                                              encoding:NSUTF8StringEncoding];

    [_data release];
    _data = nil;

    NSString *jsString = @"<script type='text/javascript'>\
    window.external =\
    {\
    'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },\
    'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\
    }\
    </script>";

   //Here appending the above javascript with content

    content = [jsString stringByAppendingString:content];

    NSURL *url = [[NSURL alloc] initWithString:@"https://converse.accesscontrol"];

    [webView loadHTMLString:content baseURL:url];
   }
   }

Gmail や Yahoo にログインすると、以下のコードが実行され、URL を確認しますが、ここで (条件が失敗した場合)。上記のリンクを参照してください。

 - (BOOL)webView:(UIWebView *)webView
  shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType

{

_url = [[NSURL alloc] initWithString:@"https://converse.accesscontrol.windows"];

  if(_url)
  {

    if([_url isEqual:[request URL]])
    {
        return YES;
    }

    [_url release];
  }

  _url = [[request URL] retain];
   NSString* scheme = [_url scheme];

  if([scheme isEqualToString:@"acs"])
   {
    // parse the JSON URL parameter into a dictionary
    NSDictionary* pairs = [self parsePairs:[_url absoluteString]];
    if(pairs)
    {
        WACloudAccessToken* accessToken;
        accessToken = [[WACloudAccessToken alloc] initWithDictionary:pairs];
        [WACloudAccessControlClient setToken:accessToken];

        [self dismissModalViewControllerAnimated:YES];
    }

    return NO;
   }

   [NSURLConnection connectionWithRequest:request delegate:self];

   return NO;

  }

何か案は?前もって感謝します。

4

1 に答える 1

0

あなたは正常にデバイストークンを取得しました.....

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    
    
  
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
   [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    self.strToken = [[[[deviceToken description]
                       stringByReplacingOccurrencesOfString: @"<" withString: @""]
                      stringByReplacingOccurrencesOfString: @">" withString: @""]
                     stringByReplacingOccurrencesOfString: @" " withString: @""];
    
    NSLog(@"%@",deviceToken);
}


- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSString *str = [NSString stringWithFormat: @"Error: %@", error];
   
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    
    NSLog(@"user info  %@",userInfo);
    UIApplicationState state = [application applicationState];
    if (state == UIApplicationStateActive) {
        NSString *cancelTitle = @"OK";
        //NSString *showTitle = @"Show";
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles: nil];
        [alertView show];
        [alertView release];
        
        
    } 
   else {
        //Do stuff that you would do if the application was not active
    }
}
于 2013-05-02T07:20:24.040 に答える