2016-05-10 57 views
1

我正在嘗試使用Twilio sdk但我的電話在2或3秒內斷開連接。我的Twilio帳戶已被整合。我使用下面的代碼我想打電話使用Twilio sdk,但我的電話在2或3秒內斷開

-(IBAction)mainButtonPressed:(id)sender 
    { 
     BasicPhoneAppDelegate* delegate = (BasicPhoneAppDelegate*)[UIApplication sharedApplication].delegate; 
     BasicPhone* basicPhone = delegate.phone; 

     if (!basicPhone.connection || basicPhone.connection.state == TCConnectionStateDisconnected) 
     { 
      NSString* strToNumber = self.textOutgoingDest.text; 
      if (strToNumber && ![strToNumber isEqualToString:@""]) { 

       switch (_eOutgoingType) { 
        case BPOutgoingNumber: 
         break; 

        case BPOutgoingClient: 
         strToNumber = [NSString stringWithFormat:@"client:%@", strToNumber]; 
         break; 

        default: 
         break; 
       } 

       NSDictionary* dictParams = [NSDictionary dictionaryWithObjectsAndKeys:strToNumber, @"To", nil]; 
       [self.phone connectWithParams:dictParams]; 
      } 
      else { 
       [self.phone connectWithParams:nil]; 
      } 
     } 
     else 
     { 
      [basicPhone disconnect]; 
     } 

     [self syncMainButton]; 
    } 

回答

1

我已經解決了我的問題

-(IBAction)mainButtonPressed:(id)sender 
{ 
    BasicPhoneAppDelegate* delegate = (BasicPhoneAppDelegate*)[UIApplication sharedApplication].delegate; 
    BasicPhone* basicPhone = delegate.phone; 

    if (!basicPhone.connection || basicPhone.connection.state == TCConnectionStateDisconnected) 
    { 
     NSString* strToNumber = self.textOutgoingDest.text; 
     if (strToNumber && ![strToNumber isEqualToString:@""]) 
     { 
      strToNumber = [NSString stringWithFormat:@"%@", strToNumber]; 
      NSDictionary* dictParams = [NSDictionary dictionaryWithObjectsAndKeys:strToNumber, @"number", nil]; 
      [self.phone connectWithParams:dictParams]; 
     } 
     else 
     { 
      [self.phone connectWithParams:nil]; 
     } 
    } 
    else 
    { 
     [basicPhone disconnect]; 
    } 

    [self syncMainButton]; 
}