Skip to content

Commit

Permalink
[feature][SDK-126] Add setLanguage method
Browse files Browse the repository at this point in the history
  • Loading branch information
wfhm committed Sep 14, 2023
1 parent 0f6cbb1 commit 2edac9d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ public void process(@NonNull final Result<String, UnregisterForPushNotificationE
return true;
}

@CordovaMethod
private boolean setLanguage(JSONArray data, final CallbackContext callbackContext)
{
try
{
String language = data.getString(0);
Pushwoosh.getInstance().setLanguage(language);
}
catch (JSONException e)
{
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
}
return true;
}

@CordovaMethod
private boolean setTags(JSONArray data, final CallbackContext callbackContext) {
JSONObject params;
Expand Down
5 changes: 5 additions & 0 deletions src/ios/PushNotification.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ - (void)unregisterDevice:(CDVInvokedUrlCommand *)command {
}];
}

- (void)setLanguage:(CDVInvokedUrlCommand *)command {
NSString *language = command.arguments[0];
[[Pushwoosh sharedInstance] setLanguage:language];
}

- (void)startBeaconPushes:(CDVInvokedUrlCommand *)command {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand Down
11 changes: 11 additions & 0 deletions www/PushNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ PushNotification.prototype.clearLaunchNotification = function(callback) {
exec(callback, callback, "PushNotification", "clearLaunchNotification", []);
};

//Function: setLanguage
//[android, ios] Set custom application language (as opposed to the default system language).
//This allows sending localized push messages
//
//Parameters:
// "language" - string containing language code, i.e. "en", "fr"
//
PushNotification.prototype.setLanguage = function(language) {
exec(null, null, "PushNotification", "setLanguage", [language]);
};

//Function: setUserId
//[android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
//This allows data and events to be matched across multiple user devices.
Expand Down

0 comments on commit 2edac9d

Please sign in to comment.