Home > Enterprise >  Application is crash after tap on notification
Application is crash after tap on notification

Time:11-11

When I receive notification and tap of it while app is hide\sleep or open - it is work normally and opening.
When I try tap of notification when app is close it trying start and crash\down.

Device logs in crash moment:

> Time  Device Name Type    PID Tag Message Nov  4
> 01:56:22  iPhone-Sofia    Error   44  WirelessRadioManagerd(MobileWiFi)   WiFiDeviceClientCopyCurrentNetwork:
> server port [22359] Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(<private>) state data format error:
> <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   110 symptomsd(SymptomEvaluator) COSMCtrl
> _foregroundAppActivity incoming bundle com.companyname.DriverHelperv2 has nil supplied UUID, finds existing
> D684E87E-097C-3D1A-96A5-B05EE0500BFA Nov  4
> 01:56:19  iPhone-Sofia    Error   32  runningboardd(RunningBoardServices) Unable
> to get short BSD proc info for 1265: No such process Nov  4
> 01:56:19  iPhone-Sofia    Error   32  runningboardd(RunningBoardServices) Unable
> to get short BSD proc info for 1265: No such process Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(SplashBoard)    Snapshot
> generation request for bundleID: com.companyname.DriverHelperv2
> rejected due to the app being denylisted. Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Ignoring update
> for invalidated scene: sceneID:com.companyname.DriverHelperv2-default
> Nov  4 01:56:19   iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281bca6a0; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281bca460; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Fault   61  SpringBoard(ApplePushService)   Unable to
> move topic <private>, This topic was not in the list provided!
> APSTopicListOpportunistic Nov  4
> 01:56:19  iPhone-Sofia    Error   86  rapportd(MobileWiFi)    WiFiDeviceClientCopyCurrentNetwork:
> server port [16139] Nov  4
> 01:56:19  iPhone-Sofia    Error   65  sharingd(MobileWiFi)    WiFiDeviceClientCopyCurrentNetwork:
> server port [47879] Nov  4
> 01:56:19  iPhone-Sofia    Error   87  bluetoothd(MobileWiFi)  WiFiDeviceClientCopyCurrentNetwork:
> server port [45583] Nov  4
> 01:56:19  iPhone-Sofia    Error   87  bluetoothd(MobileWiFi)  WiFiDeviceClientCopyCurrentNetwork:
> server port [45583] Nov  4
> 01:56:19  iPhone-Sofia    Error   65  sharingd(MobileWiFi)    WiFiDeviceClientCopyCurrentNetwork:
> server port [47879] Nov  4
> 01:56:19  iPhone-Sofia    Error   86  rapportd(MobileWiFi)    WiFiDeviceClientCopyCurrentNetwork:
> server port [16139] Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(RunningBoardServices)   Error
> acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2
> "Specified target process does not exist"
> UserInfo={NSLocalizedFailureReason=Specified target process does not
> exist}> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Unable to get
> short BSD proc info for 1265: No such process Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Unable to get
> short BSD proc info for 1265: No such process Nov  4
> 01:56:19  iPhone-Sofia    Error   32  runningboardd(RunningBoard) RBSStateCapture
> remove item called for untracked item <RBProcessMonitorObserver| qos:0
> qos:(null) configs:{ Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281af6e50; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(KeyboardArbiter)    [<_UIKeyboardArbiter:
> 0x282dfd860; <<_UIKeyboardArbiter_ForSpringBoard: 0x2818b2fa0>; scene
> = <FBSScene: 0x283845900; identifier: com.apple.UIKit.remote-keyboard; valid: YES> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281bcdd40; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281bb0090; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(FrontBoard) Scene
> FBSceneManager/sceneID:com.companyname.DriverHelperv2-default update
> failed: <NSError: 0x281bb63a0; domain: FBSceneErrorDomain; code: 1
> (operation-failed); reason: "Scene update failed."> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(KeyboardArbiter)    [<_UIKeyboardArbiter:
> 0x282dfd860; <<_UIKeyboardArbiter_ForSpringBoard: 0x2818b2fa0>; scene
> = <FBSScene: 0x283845900; identifier: com.apple.UIKit.remote-keyboard; valid: YES> { Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(SpringBoard)    Didn't find
> grabberView for <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   61  SpringBoard(SpringBoard)    Didn't find
> grabberView for <private> Nov  4
> 01:56:19  iPhone-Sofia    Error   173 appstored   StoreKitServiceConnection(1265):
> No active account to check messages Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /sbin/lldb Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /bin/lldb Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /usr/bin/lldb Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /sbin/gdb Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /bin/gdb Nov  4
> 01:56:19  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /usr/bin/gdb Nov  4
> 01:56:17  iPhone-Sofia    Error   44  WirelessRadioManagerd(MobileWiFi)   WiFiDeviceClientCopyCurrentNetwork:
> server port [22359] Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(BaseBoard)  Error:
> BSLogAddStateCaptureBlockWithTitle(SpringBoard -
> SBInCallPresentationSession) state data format error: <private> Nov  4
> 01:56:17  iPhone-Sofia    Error   0   kernel(Sandbox) Sandbox: DriverHelper v
> 2(1265) deny(2) file-test-existence /private/etc/.mdns_debug Nov  4
> 01:56:17  iPhone-Sofia    Fault   61  SpringBoard(ApplePushService)   Unable to
> move topic <private>, This topic was not in the list provided!
> APSTopicListEnabled Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(UserNotificationsServer)    No
> data found at
> /var/mobile/Library/UserNotifications/6ED3F957-7264-4CED-A562-293091D3EB68/Categories.plist
> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(UserNotificationsServer)    No
> data found at
> /var/mobile/Library/UserNotifications/6ED3F957-7264-4CED-A562-293091D3EB68/Categories.plist
> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(UserNotificationsServer)    No
> data found at
> /var/mobile/Library/UserNotifications/6ED3F957-7264-4CED-A562-293091D3EB68/PendingNotifications.plist
> Nov  4
> 01:56:17  iPhone-Sofia    Error   61  SpringBoard(SplashBoard)    Snapshot
> generation request for bundleID: com.companyname.DriverHelperv2
> rejected due to the app being denylisted. Nov  4
> 01:56:17  iPhone-Sofia    Error   32  runningboardd(RunningBoard) 1265
> setGPURole failed with result = e00002c7 Nov  4
> 01:56:17  iPhone-Sofia    Error   0   kernel(IOBiometricFamily)   IOSEPBiometricService::sksQueueDequeue
> -> err:0xe00002f0 Nov  4 01:56:17 iPhone-Sofia    Error   61  SpringBoard(UserNotificationsServer)    No
> data found at
> /var/mobile/Library/UserNotifications/6ED3F957-7264-4CED-A562-293091D3EB68/Categories.plist

AppDelegate:

[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate, IUNUserNotificationCenterDelegate, IMessagingDelegate
{
    //
    // This method is invoked when the application has loaded and is ready to run. In this 
    // method you should instantiate the window, load the UI into it and then make the window
    // visible.
    //
    // You have 17 seconds to return from this method, or iOS will terminate your application.
    //
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();

        LoadApplication(new App());

        Firebase.Core.App.Configure();

        // Register your app for remote notifications.
        if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
        {
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.Current.Delegate = this;

            var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
            UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
                //Console.WriteLine(granted);
            });
        }
        else
        {
            // iOS 9 or before
            var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
            var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
        }

        UIApplication.SharedApplication.RegisterForRemoteNotifications();

        Messaging.SharedInstance.Delegate = this;

        //var token = Messaging.SharedInstance.FcmToken ?? "";
        return base.FinishedLaunching(app, options);
    }

    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
    {
        Messaging.SharedInstance.ApnsToken = deviceToken;
        //string token = NSUserDefaults.StandardUserDefaults.StringForKey("token");
        //string DeviceToken = deviceToken.ToString().Replace("<", string.Empty).Replace(">", string.Empty).Replace(" ", string.Empty);
    }

    [Export("messaging:didReceiveRegistrationToken:")]
    public async void DidReceiveRegistrationToken(Messaging messaging, string fcmToken)
    {
        await SecureStorage.SetAsync("FCMToken", fcmToken);

        // TODO: If necessary send token to application server.
        // Note: This callback is fired at each app startup and whenever a new token is generated.
    }
    public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
    {
        // If you are receiving a notification message while your app is in the background,
        // this callback will not be fired till the user taps on the notification launching the application.
        // TODO: Handle data of notification

        // With swizzling disabled you must let Messaging know about the message, for Analytics
        //Messaging.SharedInstance.AppDidReceiveMessage (userInfo);

        // Print full message.
        //Console.WriteLine(userInfo);
    }

    public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
    {
        // If you are receiving a notification message while your app is in the background,
        // this callback will not be fired till the user taps on the notification launching the application.
        // TODO: Handle data of notification

        // With swizzling disabled you must let Messaging know about the message, for Analytics
        //Messaging.SharedInstance.AppDidReceiveMessage(userInfo);

        // Print full message.
        //Console.WriteLine(userInfo);


        completionHandler(UIBackgroundFetchResult.NewData);
    }

    // Receive displayed notifications for iOS 10 devices.
    // Handle incoming notification messages while app is in the foreground.
    [Export("userNotificationCenter:willPresentNotification:withCompletionHandler:")]
    public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
    {
        //var userInfo = notification.Request.Content.UserInfo;

        // With swizzling disabled you must let Messaging know about the message, for Analytics
        //Messaging.SharedInstance.AppDidReceiveMessage (userInfo);

        // Print full message.
        //Console.WriteLine(userInfo);

        // Change this to your preferred presentation option
        completionHandler(UNNotificationPresentationOptions.Banner);
    }

    // Handle notification messages after display notification is tapped by the user.
    [Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
    public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
    {
        var userInfo = response.Notification.Request.Content.UserInfo;
        var actionValue = userInfo.ObjectForKey(new NSString("Action")) as NSString;

        string actionName = actionValue.ToString();

        INotificationHandler notificationHandler = DependencyService.Get<INotificationHandler>();

        switch (actionName)
        {
            case "Re-registration": //Перерегистрация
                notificationHandler.CallReRegistrPage();
                break;
            case "New-route": //Новый рейс
                notificationHandler.CallMainPageRouteRefreshPage();
                break;
            case "Simple-message": //Входящие уведомления
                notificationHandler.CallInboundMessagesPage();
                break;
            case "Finalization": //Входящие финализация
                notificationHandler.CallFinalizationPage();
                break;
            case "Alarm": //Будильник
                notificationHandler.CallInboundMessagesPage();
                break;
            case "Geofences-message": //Сообщение с геозонами отдыха
                notificationHandler.CallInboundMessagesPage();
                break;
        }

        // Print full message.
        //Console.WriteLine(userInfo);

        completionHandler();
    }
}

It looks like code even not enter FinishedLaunching method. I mean app is crash earlier than FinishedLaunching start.

CodePudding user response:

Problem was in not start PLC app, but I tried redirect to messages page. And this is my solution:
I created dependency action event in PLC project:

public interface ILoaded
{
    event Action ILoaded;
    void ItsLoad();
}  

I subscribe of it in FinishedLaunching:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    _options = options;

    global::Xamarin.Forms.Forms.Init();

    LoadApplication(new App());

    DependencyService.Get<ILoaded>().ILoaded  = AppDelegate_ILoaded;

    Firebase.Core.App.Configure();

    // Register your app for remote notifications.
    if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
    {
        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.Current.Delegate = this;

        var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
        UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
            //Console.WriteLine(granted);
        });
    }
    else
    {
        // iOS 9 or before
        var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
        var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
        UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
    }

    UIApplication.SharedApplication.RegisterForRemoteNotifications();

    Messaging.SharedInstance.Delegate = this;


    //var token = Messaging.SharedInstance.FcmToken ?? "";
    return base.FinishedLaunching(app, options);
}  

And now I understand when I app start from notification tap.

private void AppDelegate_ILoaded()
{
    if (!_itsLoad && _options != null)
    {
        ProcessingMessage(_options);
        _itsLoad = true;
    }
}  

In PLC project it is looks like this:

DependencyService.Get<ILoaded>().ItsLoad();  

I call it when PLC mainpage is start.

And for sum up:

If app hide or open I call method ProcessingMessage from DidReceiveNotificationResponse

[Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
    public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
    {
        if (_itsLoad)
        {
            ProcessingMessage(response.Notification.Request.Content.UserInfo);
            completionHandler();
        }
    }  

If app is closed, I call from event.

ProcessingMessage method:

private void ProcessingMessage(NSDictionary data)
{
    if(data.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
    {
        data = (NSDictionary)data[UIApplication.LaunchOptionsRemoteNotificationKey];
    }

    var actionValue = data.ObjectForKey(new NSString("Action")) as NSString;
    string actionName = actionValue.ToString();

    if (!string.IsNullOrEmpty(actionName))
    {
        INotificationHandler notificationHandler = DependencyService.Get<INotificationHandler>();

        switch (actionName)
        {
            case "Re-registration": //Перерегистрация
                notificationHandler.CallReRegistrPage();
                break;
            case "New-route": //Новый рейс
                notificationHandler.CallMainPageRouteRefreshPage();
                break;
            case "Simple-message": //Входящие уведомления
                notificationHandler.CallInboundMessagesPage();
                break;
            case "Finalization": //Входящие финализация
                notificationHandler.CallFinalizationPage();
                break;
            case "Alarm": //Будильник
                notificationHandler.CallInboundMessagesPage();
                break;
            case "Geofences-message": //Сообщение с геозонами отдыха
                notificationHandler.CallInboundMessagesPage();
                break;
        }
    }
}
  • Related