簡體   English   中英

是否可以使用Xcode中的臨時配置文件來調試我的應用程序?

[英]Is it possible to debug my app with adhoc provisioning profile in Xcode?

如您所知,我將“簽名調試”配置文件設置為Adhoc供應配置文件。

如果我在iPhone上運行應用程序,則可以使用iPhone接收后台的遠程推送通知(后台使用分發配置文件,因此必須使用即席或分發配置文件)。

但是每次我在iPhone上運行該應用程序(使用Adhoc配置文件)時,它將斷開連接:

無法啟動“項目名稱”
進程啟動失敗:無法獲得進程xxx的任務

因此,我無法使用Xcode中的真實設備調試我的應用程序(使用Adhoc供應配置文件),有什么辦法嗎?

我的要求是轉到特殊的vc ,在didFinishLaunchingWithOptions方法中的代碼如下:

// If application is launched due to  notification,present another view controller.
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (notification)
{
    [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"success"]];

    PushDetailViewController *detail_push = [[PushDetailViewController alloc] init];
    detail_push.isPresentCome = YES;

    PushModel *new_model = [PushModel initPushModelWithDic:notification.userInfo];

    if (new_model) {

        detail_push.pushModel = new_model;

        [self.window.rootViewController presentViewController:detail_push animated:NO completion:nil];

    }

}else {

    //LMLSystemAlertControllerShowSingelButtonWithMessageWL(@"沒有notification 信息", @"確定");
}

return YES;

而且我不知道notification.userInfo是什么,所以我想調試它,並且如果我使用SVProgressHUD發出警報,則我的應用程序將崩潰,因為我的iPhone與Xcode SVProgressHUD連接,所以我無法獲取錯誤信息。

因此,存在一些問題:

  1. 是否可以在Xcode中用iphone調試我的應用程序(使用臨時配置文件)?
  2. notification.userInfo的內容是什么,這是我從后台返回的推送內容嗎?
  3. 我的推送內容(來自后台)在哪里?

嘗試-1

我試圖提醒notification.userInfo ,但是如果我訪問notification.userInfo ,我的應用程序將崩潰,因此我無法獲取它,也不知道它是什么。

嘗試-2

我也使用Xcode-> Deveice查找NSLog信息,什么也沒找到:

在此處輸入圖片說明

對於調試UserInfo:放置NSLOG以打印UserInfo,然后檢查值是否正確輸入。 我知道您無法在Xcode控制台中檢查NSLOG,但可以在Xcode中的“設備”中檢查NSLOG。 Xcode->窗口->設備->在左側面板中選擇您的設備。 在這里您可以看到所有日志。

根據UserInfo詳細信息,您可以驗證代碼是否正確。

要在Adhoc構建模式下調試推送通知有效負載,只需將UIAlertView放置在所需位置即可。 並可以在iPhone屏幕上看到輸出。 :)

例如您的情況。

NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (notification)
    {
        NSDictionary *apsInfo = [notification objectForKey:@"aps"];
        // Put AlertView here
        UIAlertView *alert =[[UIAlertView alloc]
        initWithTitle:@"NotificationPayload"
        message:[NSString stringWithFormat:@"%@",apsInfo]
        delegate:self
        cancelButtonTitle:@"Ok"
        otherButtonTitles: nil];
        [alert show];

        [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"success"]];

        PushDetailViewController *detail_push = [[PushDetailViewController alloc] init];
        detail_push.isPresentCome = YES;
        PushModel *new_model = [PushModel initPushModelWithDic:apsInfo];

        if (new_model) {
            detail_push.pushModel = new_model;
            [self.window.rootViewController presentViewController:detail_push animated:NO completion:nil];
        }

    }
    else {
         //LMLSystemAlertControllerShowSingelButtonWithMessageWL(@"沒有notification 信息", @"確定");
}

return YES;

完成調試后,請不要忘記評論或刪除此AlertView代碼。

我不確定我是否能正確理解您的問題,但是聽起來您在測試推送通知時遇到問題,因為您使用的是“生產”推送證書,因此嘗試在其中使用Ad-Hoc設置配置文件進行調試為了接收通知?

在這種情況下,解決方案是更新您的推送證書。 我們不再需要為“沙盒”使用一個證書,而為“生產”使用另一個證書-新的推送證書在兩種環境中均有效。 因此,您應該能夠使用開發配置文件在Xcode中正常構建和調試應用,並且仍然會收到通知。

現在在“沙盒和生產”中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM