diff --git a/Parse/Parse/Parse.h b/Parse/Parse/Parse.h index 8f11dab62..52e76fa1d 100644 --- a/Parse/Parse/Parse.h +++ b/Parse/Parse/Parse.h @@ -106,6 +106,16 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, nullable, readonly, class) ParseClientConfiguration *currentConfiguration; +/** + Sets the server URL to connect to Parse Server. The local client cache is not cleared. + @discussion This can be used to update the server URL after this client has been initialized, without having to destroy this client. An example use case is + server connection failover, where the clients connects to another URL if the server becomes unreachable at the current URL. + @warning The new server URL must point to a Parse Server that connects to the same database. Otherwise, issues may arise + related to locally cached data or delayed methods such as saveEventually. + @param server The server URL to set. + */ ++ (void)setServer:(nonnull NSString *)server; + /** The current application id that was used to configure Parse framework. */ @@ -120,6 +130,11 @@ NS_ASSUME_NONNULL_BEGIN + (nullable NSString *)getClientKey PARSE_DEPRECATED("Use clientKey property."); +/** + The current server URL to connect to Parse Server. + */ +@property (nonatomic, nullable, readonly, class) NSString *server; + ///-------------------------------------- #pragma mark - Enabling Local Datastore ///-------------------------------------- diff --git a/Parse/Parse/Parse.m b/Parse/Parse/Parse.m index 9f84aed79..3ba063247 100644 --- a/Parse/Parse/Parse.m +++ b/Parse/Parse/Parse.m @@ -89,6 +89,10 @@ + (void)initializeWithConfiguration:(ParseClientConfiguration *)configuration { [[self parseModulesCollection] parseDidInitializeWithApplicationId:configuration.applicationId clientKey:configuration.clientKey]; } ++ (void)setServer:(nonnull NSString *)server { + [PFInternalUtils setParseServer:server]; +} + + (nullable ParseClientConfiguration *)currentConfiguration { return currentParseManager_.configuration; } @@ -113,6 +117,10 @@ + (nullable NSString *)getClientKey { return [self clientKey]; } ++ (nullable NSString *)server { + return [[PFInternalUtils parseServerURLString] copy]; +} + ///-------------------------------------- #pragma mark - Extensions Data Sharing ///--------------------------------------