Giter Club home page Giter Club logo

Comments (13)

neHCuoHEpa avatar neHCuoHEpa commented on June 24, 2024 8

Full code solution. Add that script to any Editor folder, should be fix the problem

public class ApplePostProcess : MonoBehaviour
{
#if UNITY_IOS
    [PostProcessBuild(1)]
    public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToXcode)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            FixediOS13NotificationBug(pathToXcode);
        }
    }
    private static void FixediOS13NotificationBug(string pathToXcode)
    {
        string managerPath = pathToXcode + "/Libraries/com.unity.mobile.notifications/Runtime/iOS/Plugins/UnityNotificationManager.m";
        var text = File.ReadAllLines(managerPath).ToList();
        for (int i = 0; i < text.Count; i++)
        {
            if (text[i] == @"- (void)updateScheduledNotificationList")
            {
                text.RemoveRange(i, 7);
                text.Insert(i, @"- (void)updateScheduledNotificationList
{
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    if (@available(iOS 15, *))
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray < UNNotificationRequest *> *_Nonnull requests) {
                self.cachedPendingNotificationRequests = requests;
            }];
        });
    }
    else
    {
        [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray < UNNotificationRequest *> *_Nonnull requests) {
            self.cachedPendingNotificationRequests = requests;
        }];
    }

}");
                break;
            }
        }
        
        File.WriteAllLines(managerPath, text.ToArray());
    }
#endif
}

from com.unity.mobile.notifications.

yanmasharski avatar yanmasharski commented on June 24, 2024 3

Little bit improved solution

- (void)updateScheduledNotificationList
{
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    if (@available(iOS 15, *)) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
                    self.cachedPendingNotificationRequests = requests;
            }];
        });
    } else {
        [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
                self.cachedPendingNotificationRequests = requests;
        }];
    }
        
}

from com.unity.mobile.notifications.

mpeggdev avatar mpeggdev commented on June 24, 2024 1

Thanks to the above comment we also managed to fix the issue. However, we chose to use dispatch_async rather than once so subsequent calls to the function will also work:

- (void)updateScheduledNotificationList
{
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    dispatch_async(dispatch_get_main_queue(), ^{
        [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
                self.cachedPendingNotificationRequests = requests;
        }];
    });
}

from com.unity.mobile.notifications.

ddalacu avatar ddalacu commented on June 24, 2024

We had the same issue and the posted fix by mpdggdev fixed it for us too.

from com.unity.mobile.notifications.

aurimasc avatar aurimasc commented on June 24, 2024

Under what conditions does this occur?
I cannot reproduce this issue using latest notifications package.

from com.unity.mobile.notifications.

mpeggdev avatar mpeggdev commented on June 24, 2024

We found that the issue occurs when either Firebase or Pangle (or both) are present in a project.

from com.unity.mobile.notifications.

celp avatar celp commented on June 24, 2024

Is there any progress?
I'm worried because I need to remember to fix it every time I build, and if I forget, the app won't start.

Thank you,

from com.unity.mobile.notifications.

aurimasc avatar aurimasc commented on June 24, 2024

@celp could you submit a bug via Unity Editor with the project in which it reproduces?
Link this issue in the bug report.

from com.unity.mobile.notifications.

celp avatar celp commented on June 24, 2024

@aurimasc
OK, I will submit it.

from com.unity.mobile.notifications.

celp avatar celp commented on June 24, 2024

@aurimasc
I submitted a bug report from the Unity Editor with a project to reproduce.
Please check it.
Case: 1375744

from com.unity.mobile.notifications.

celp avatar celp commented on June 24, 2024

I found that the problem occurs with the combination of Xcode 13 and iOS 15.

from com.unity.mobile.notifications.

celp avatar celp commented on June 24, 2024

Hi All,
I just received a message from Unity that the issue has been added to the Issue Tracker.
I'm waiting for the fix.

https://issuetracker.unity3d.com/issues/ios-app-freezes-slash-crashes-when-both-mobile-notifications-and-firebase-are-used

from com.unity.mobile.notifications.

aurimasc avatar aurimasc commented on June 24, 2024

Should be fixed by this: #130

from com.unity.mobile.notifications.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.