Skip to content

[question]: OneSignal 5.0 iOS PushSubscription.Id crash and PreventDefualt still displaying on iOSΒ #628

@mpiechocki

Description

@mpiechocki

How can we help?

General question is: how do I initialise OneSignal Unity SDK properly on iOS, in version 5.0.0? I'm using OneSignal for pushes only.
What I'm currently doing, is that after logging user in, I need to set the subscription id to our server, so that it can authorise the pushes properly.
The initialization code is as follows:

OneSignal.Debug.LogLevel = LogLevel.Verbose;
OneSignal.Debug.AlertLevel = LogLevel.Fatal;

OneSignal.Initialize(appId);

OneSignal.Notifications.ForegroundWillDisplay += OnForegroundWillDisplay;
OneSignal.Notifications.Clicked += OnNotificationClicked;
OneSignal.User.PushSubscription.Changed += OnPushSubscriptionChanged;

if (!Settings.ShownPushNotificationsPrompt)
{
    await OneSignal.Notifications.RequestPermissionAsync(true);
    Settings.ShownPushNotificationsPrompt = true;
}

And then, when the session is opened, and I know the user, I call:

OneSignal.Login(user.Id);
UpdatePushToken(OneSignal.User.PushSubscription.Id);

The problem is that on Android, this code works just fine and pushes work as expected. But on iOS, this results in a runtime crash:

2023-08-20 11:44:40.508795+0200 Highrise[29784:1472087] VERBOSE: OneSignal.User login called with externalId: 64a410b70003f4277b2958df
2023-08-20 11:44:40.508948+0200 Highrise[29784:1472087] VERBOSE: OneSignalUserManager internal _login called with externalId: 64a410b70003f4277b2958df
2023-08-20 11:44:40.509024+0200 Highrise[29784:1472087] VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.)
Highrise(29784,0x104e3c580) malloc: *** error for object 0x283da69d1: pointer being freed was not allocated
Highrise(29784,0x104e3c580) malloc: *** set a breakpoint in malloc_error_break to debug

I tried to guard against nulls, but still, the result is the same. I tried to look into OneSignal objc code and found something that worries me a little bit:
Screenshot 2023-08-20 at 11 49 57
as the propery name is id which is a keyword in objc, but I'm not actually sure it's the problem.

Can anybody point me to any direction on what might be an issue here? Thanks!

P.S. The problem we're trying to actually solve with upgrading to 5.0.0 is that we still didn't find a workaround for getting pushes in foreground bug (see #521) so if anyone has any workaround for this on OneSignal 4.8.3, I'd be happy to hear it :)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions