Unity-Technologies / NotificationsSamples

Sample project for Unity Notifications
Other
282 stars 51 forks source link

ArgumentNullException: Value cannot be null when initializing channel #41

Closed ghost closed 4 years ago

ghost commented 4 years ago

I have a scene with just two game objects. During the wrapping the channel in an Android object, I get a null reference error.

            // Wrap channel in Android object
            var androidChannel = new AndroidNotificationChannel(notificationChannel.Id, notificationChannel.Name,
                                                                notificationChannel.Description,
                                                                (Importance)notificationChannel.Style)
            {
                CanBypassDnd = notificationChannel.HighPriority,
                CanShowBadge = notificationChannel.ShowsBadge,
                EnableLights = notificationChannel.ShowLights,
                EnableVibration = notificationChannel.Vibrates,
                LockScreenVisibility = (LockScreenVisibility)notificationChannel.Privacy,
                VibrationPattern = vibrationPattern
            };

I followed the steps of creating an object with the GameNotificationsManager and created a script which references it and initializes it using the following code

    void Start() {
        Debug.Log("Initializing channels");
        var c1 = new GameNotificationChannel(TimerChannelId, "Timer Game Channel", "Timer notifications");
        gameNotificationsManager.Initialize(c1);
    }

to get ArgumentNullException: Value cannot be null.

This works in the repo project but not mine. Anyone have any ideas on how I should fix this?

KuzyT commented 4 years ago

If someone have a same issue - check that you are using correct plugin version.

GTadeon commented 3 years ago

go to your unity manifest file, find mobilenotification package version ,check that it matches the one from the source project, also copy paste source project's editor folder content to yours (so that you're sure that you have exactly that version of the package). This solved it for me