Unity Mobile Notification (IOS): How to fix app's crash with reason
[NSString stringWithUTF8String:]: NULL cString

Unity Mobile Notification (IOS): How to fix app's crash with reason [NSString stringWithUTF8String:]: NULL cString

One of our main goals is to make our game android game Aurion KGF available for IOS players.

The mobile notification package is present in our android version and we also need to allow ios players to receive a notification when something happens in the game.

So we added the package via the package manager, adapted our android code and now generated the xcode project.

From the xcode project, we launch the game and the game crashes at a particular location with the crash details :

NSInvalidArgumentException', reason : '*** + [NSString stringWithUTF8String :]: NULL cString'.

Xcode does not tell you the line of code that creates the problem but the information is clear you have a null string in your code that creates the crash.

So in our case, the crash occurred when we added the mobile notification package and adapted our code. 

To solve this problem, look in your code for cases where you can have a null or empty string.

In our case, we need to cancel the notification and the RemoveScheduledNotification method of iOSNotificationCenter takes an identifier as a parameter, so if the identifier is null or empty, our application will crash.

Click here to get mobile notification documentation for IOS.

Thanks for reading. 😜 


Eugene Voitovich

Head of R&D at Veryo Studios

1y

You just saved me a lot of time, thank you!

Like
Reply
Olivier Madiba

Building fun & inspiring games with Kiroo Games | Wallbreakers Big Boss |

2y

Bravo c'est bien de publier. Hésite pas à me tag pour que je share souvent

Like
Reply

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics