Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get and set server #1464

Merged
merged 3 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Parse/Parse/Parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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
///--------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions Parse/Parse/Parse.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -113,6 +117,10 @@ + (nullable NSString *)getClientKey {
return [self clientKey];
}

+ (nullable NSString *)server {
return [[PFInternalUtils parseServerURLString] copy];
}

///--------------------------------------
#pragma mark - Extensions Data Sharing
///--------------------------------------
Expand Down