Skip to content

Commit

Permalink
Merge pull request #75 from Pushwoosh/feature/SDK-442-xcframework-Uni…
Browse files Browse the repository at this point in the history
…ty-Pushwoosh-plugin

[feature][SDK-442] xcframework added, ```setLanguage``` method added
  • Loading branch information
akidisdev authored Nov 19, 2024
2 parents a6866b7 + 583ecef commit cd8d7f5
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ public void setUserId(String userId) {
PushwooshInApp.getInstance().setUserId(userId);
}

public void setLanguage(String language) {
Pushwoosh.getInstance().setLanguage(language);
}

public void setUser(String userId, List<String> emails) {
Pushwoosh.getInstance().setUser(userId, emails);
}
Expand Down
11 changes: 6 additions & 5 deletions PushwooshUnitySample/Assets/Editor/PushwooshBuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ public class PushwooshBuildManager : MonoBehaviour
[PostProcessBuild(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
string preprocessorPath = path + "/Classes/Preprocessor.h";
string text = File.ReadAllText(preprocessorPath);
text = text.Replace("UNITY_USES_REMOTE_NOTIFICATIONS 0", "UNITY_USES_REMOTE_NOTIFICATIONS 1");
File.WriteAllText(preprocessorPath, text);
if (buildTarget == BuildTarget.iOS) {
string preprocessorPath = path + "/Classes/Preprocessor.h";
string text = File.ReadAllText(preprocessorPath);
text = text.Replace("UNITY_USES_REMOTE_NOTIFICATIONS 0", "UNITY_USES_REMOTE_NOTIFICATIONS 1");
File.WriteAllText(preprocessorPath, text);
}
}
#endif

Expand Down Expand Up @@ -70,7 +72,6 @@ private static void onPostProcessBuildPlayer(BuildTarget target, string pathToBu
}

File.WriteAllText(projPath, proj.WriteToString());

}
#endif

Expand Down
13 changes: 9 additions & 4 deletions PushwooshUnitySample/Assets/Plugins/iOS/UnityRuntime.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#import <UserNotifications/UserNotifications.h>
#import <objc/runtime.h>
#import <Pushwoosh/PushNotificationManager.h>
#import <Pushwoosh/Pushwoosh.h>
#import <Pushwoosh/PWInAppManager.h>
#import <Pushwoosh/PWGDPRManager.h>
#import <PushwooshFramework/PushNotificationManager.h>
#import <PushwooshFramework/PushwooshFramework.h>
#import <PushwooshFramework/PWInAppManager.h>
#import <PushwooshFramework/PWGDPRManager.h>
#import "PWMUserNotificationCenterDelegateProxy.h"

static char * g_pw_tokenStr = 0;
Expand Down Expand Up @@ -71,6 +71,11 @@ void pw_setUserId(char *userId) {
[[PWInAppManager sharedManager] setUserId:userIdStr];
}

void pw_setLanguage(char *language) {
NSString *languageStr = [[NSString alloc] initWithUTF8String:language];
[[Pushwoosh sharedInstance] setLanguage:languageStr];
}

void pw_setUser(char *userId, char **emails) {
size_t length = 0;
while (emails[length] != NULL) length++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


<dependencies>
<androidPackages>
<androidPackage spec="com.pushwoosh:pushwoosh:6.7.10"/>
Expand All @@ -11,8 +11,8 @@
</androidPackages>

<iosPods>
<iosPod name="Pushwoosh" version="6.5.14"/>
<!-- <iosPod name="Pushwoosh/Geozones"/> -->
<iosPod name="PushwooshXCFramework" version="6.7.9" addToAllTargets="true"/>
<!-- <iosPod name="PushwooshXCFramework/Geozones"/> -->
</iosPods>
</dependencies>

Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public override void SetUserId(string userId)
pushwoosh.Call("setUserId", userId);
}

public override void SetLanguage(string language)
{
pushwoosh.Call("setLanguage", language);
}

public override void SetUser(string userId, List<string> emails)
{
pushwoosh.Call("setUser", userId, emails);
Expand Down
8 changes: 8 additions & 0 deletions PushwooshUnitySample/Assets/Pushwoosh/PushNotificationsIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class PushNotificationsIOS : Pushwoosh
[System.Runtime.InteropServices.DllImport("__Internal")]
extern static private void pw_setUserId(string userId);

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static private void pw_setLanguage(string language);

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static private void pw_setUser(string userId, string[] emails);

Expand Down Expand Up @@ -151,6 +154,11 @@ public override void SetUserId(string userId)
pw_setUserId(userId);
}

public override void SetLanguage(string language)
{
pw_setLanguage(language);
}

public override void SetUser(string userId, List<string> emails)
{
List <string> stringEmails = new List<string>();
Expand Down
5 changes: 5 additions & 0 deletions PushwooshUnitySample/Assets/Pushwoosh/Pushwoosh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public virtual void SetUser(string userId, List<string> emails)
Debug.Log ("[Pushwoosh] Error: SetUser is not supported on this platform");
}

public virtual void SetLanguage(string language)
{
Debug.Log ("[Pushwoosh] Error: SetLanguage is not supported on this platform");
}

public virtual void SetEmails(List<string> emails)
{
Debug.Log ("[Pushwoosh] Error: SetEmails is not supported on this platform");
Expand Down
1 change: 1 addition & 0 deletions PushwooshUnitySample/Assets/Scripts/PushNotificator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void Start ()
Pushwoosh.Instance.SetStringTag ("UserName", "Alex");
Pushwoosh.Instance.SetIntTag ("Age", 42);
Pushwoosh.Instance.SetListTag ("Hobbies", new List<object> (new[] { "Football", "Tennis", "Fishing" }));
Pushwoosh.Instance.SetLanguage("es");

Pushwoosh.Instance.SetBadgeNumber (0);

Expand Down

0 comments on commit cd8d7f5

Please sign in to comment.