iCloud

2016-11-11 13 views
5

मैं iCloud/CloudKit साथ मेरे एप्लिकेशन में क्षेत्र सिंक करने के लिए कोशिश कर रहा हूँ के साथ क्षेत्र समन्वयन नहीं कर सकते, लेकिन सफलता नहीं मिली ...iCloud

यहाँ यह मेरे स्रोत कोड है:

-(void)sync 
{ 
    NSURL *baseURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; 

    if (baseURL) //iCloud is active 
    { 
     NSURL *serverURL = [NSURL URLWithString:@"http://myMacBookNwtworkIP:9080"]; //Realm Object Server is up and running at this URL 
     RLMSyncCredential *usernameCredential = [RLMSyncCredential credentialWithUsername:@"myUsername" 
                       password:@"myPassword" 
                        actions:RLMAuthenticationActionsUseExistingAccount]; 
     RLMSyncCredential *iCloudCredential = [RLMSyncCredential credentialWithICloudToken:@"myiCloudToken"]; 

     [RLMSyncUser authenticateWithCredential:usernameCredential 
            authServerURL:serverURL 
            onCompletion:^(RLMSyncUser *user, NSError *error) { 
             if (user) { //user recognized in my real object server 
              // can now open a synchronized RLMRealm with this user 
              RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration]; 
     /* CRASH AT THIS LINE! */   config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:user realmURL:serverURL]; 
              RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:nil];// Any changes made to this Realm will be synced across all devices! 
             } else if (error) { 
              // handle error 
              NSLog(@"error %@",error); 
             } 
            }]; 
    } 
} 

जब मैं

config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:user realmURL:serverURL]; 

exec करने की कोशिश मैं यह त्रुटि

प्रदान की URL प्राप्त (http://myMacBookNwtworkIP:9080) एक वैध दायरे यूआरएल नहीं था।

मैं इसे कैसे हल कर सकता हूं?

इसके अलावा, क्योंकि यह iCloud में कुछ सहेजने का मेरा पहला प्रयास है, मुझे iCloudCredential का उपयोग कैसे करना चाहिए? वास्तव में, यदि मैं इसके साथ usernameCredential की जगह है, तो user हमेशा नहीं के बराबर है ...

मैं इन कड़ियों पर चरणों का पालन किया:

  1. https://realm.io/docs/objc/latest/#the-realm-mobile-platform
  2. https://realm.io/docs/realm-object-server/#authentication

उत्तर

3

दुर्घटना को रोकने के लिए , "वास्तविक" प्रोटोकॉल को "http" के बजाय प्रोटोकॉल निर्दिष्ट करना आवश्यक है, जैसे

config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:user realmURL:[NSURL URLWithString:@"realm://myMacBookNwtworkIP:9080"]]; 

this link

के लिए धन्यवाद
संबंधित मुद्दे