Skip to content

Commit 7be3ea3

Browse files
mtrezzanoobs2ninjas
authored andcommitted
Add get and set server (#1464)
* add server property and setServer * removed unnecessary exception when setting server before client is initialized * amended docs
1 parent 0926ff8 commit 7be3ea3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Parse/Parse/Parse.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ NS_ASSUME_NONNULL_BEGIN
106106
*/
107107
@property (nonatomic, nullable, readonly, class) ParseClientConfiguration *currentConfiguration;
108108

109+
/**
110+
Sets the server URL to connect to Parse Server. The local client cache is not cleared.
111+
@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
112+
server connection failover, where the clients connects to another URL if the server becomes unreachable at the current URL.
113+
@warning The new server URL must point to a Parse Server that connects to the same database. Otherwise, issues may arise
114+
related to locally cached data or delayed methods such as saveEventually.
115+
@param server The server URL to set.
116+
*/
117+
+ (void)setServer:(nonnull NSString *)server;
118+
109119
/**
110120
The current application id that was used to configure Parse framework.
111121
*/
@@ -120,6 +130,11 @@ NS_ASSUME_NONNULL_BEGIN
120130

121131
+ (nullable NSString *)getClientKey PARSE_DEPRECATED("Use clientKey property.");
122132

133+
/**
134+
The current server URL to connect to Parse Server.
135+
*/
136+
@property (nonatomic, nullable, readonly, class) NSString *server;
137+
123138
///--------------------------------------
124139
#pragma mark - Enabling Local Datastore
125140
///--------------------------------------

Parse/Parse/Parse.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ + (void)initializeWithConfiguration:(ParseClientConfiguration *)configuration {
8989
[[self parseModulesCollection] parseDidInitializeWithApplicationId:configuration.applicationId clientKey:configuration.clientKey];
9090
}
9191

92+
+ (void)setServer:(nonnull NSString *)server {
93+
[PFInternalUtils setParseServer:server];
94+
}
95+
9296
+ (nullable ParseClientConfiguration *)currentConfiguration {
9397
return currentParseManager_.configuration;
9498
}
@@ -113,6 +117,10 @@ + (nullable NSString *)getClientKey {
113117
return [self clientKey];
114118
}
115119

120+
+ (nullable NSString *)server {
121+
return [[PFInternalUtils parseServerURLString] copy];
122+
}
123+
116124
///--------------------------------------
117125
#pragma mark - Extensions Data Sharing
118126
///--------------------------------------

0 commit comments

Comments
 (0)