iOS pushNotificationDelegate is not set

 We have some issue trying to create a delegate for iOS in order to save the notifications as we didn't found any information on internet could you please help us. 

 

  • What is the purpose for storing notifications into a database?

Give the user the option to review the notifications as messages in a listview 

  • What response(s) are you getting from your console log?

Application Output Log

Please ensure your device is connected...
Connected to: IPhone 5
warning MT1003: Could not kill the application '/Users/mpantaleon/Projects/ClaroEventos/iOS/bin/iPhone/Debug/build-iphone5.1-9.3.3/ClaroEventos.iOS.app'. You may have to kill the application manually.
Launched application 'com.claro.claroeventos.claroeventos' on 'IPhone 5' with pid 700
2016-08-01 21:11:14.060 ClaroEventos.iOS[700:99809] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 5
2016-08-01 21:11:14.061 ClaroEventos.iOS[700:99809] Xamarin.iOS: Processing: 'start debugger: sdb'
2016-08-01 21:11:14.061 ClaroEventos.iOS[700:99783] Xamarin.iOS: Debugger loaded with custom transport (fd: 5)
2016-08-01 21:11:14.161 ClaroEventos.iOS[700:99809] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 6
2016-08-01 21:11:14.161 ClaroEventos.iOS[700:99809] Xamarin.iOS: Processing: 'connect output'
2016-08-01 21:11:14.263 ClaroEventos.iOS[700:99809] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 7
2016-08-01 21:11:14.264 ClaroEventos.iOS[700:99809] Xamarin.iOS: Processing: 'start profiler: no'
2016-08-01 21:11:14.265 ClaroEventos.iOS[700:99783] Xamarin.iOS: Profiler not loaded (disabled)
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Mono.Dynamic.Interpreter.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.Core.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Xamarin.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.Xml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Xamarin.Forms.Platform.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Xamarin.Forms.Core.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.Net.Http.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.ServiceModel.Internals.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.Runtime.Serialization.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Xamarin.Forms.Platform.iOS.dll [External]
Thread started: Finalizer #2
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/AirshipBindings.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/SQLitePCL.batteries.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/SQLitePCL.raw.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/SQLite-net.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Xamarin.Forms.Xaml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/ClaroEventos.dll
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Parse.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/ClaroEventos.iOS.exe
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/System.Xml.Linq.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Mono.CSharp.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Microsoft.CSharp.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/33E41797-F544-42A4-B711-11CC0C246762/ClaroEventos.iOS.app/.monotouch-32/Newtonsoft.Json.dll [External]
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
2016-08-01 21:11:16.858 ClaroEventos.iOS[700:99783] [W] -[UAConfig validate] [Line 239] Production App Key is not valid.
2016-08-01 21:11:16.859 ClaroEventos.iOS[700:99783] [W] -[UAConfig validate] [Line 243] Production App Secret is not valid.
2016-08-01 21:11:16.859 ClaroEventos.iOS[700:99783] [I] +[UAirship executeUnsafeTakeOff:] [Line 205] UAirship Take Off! Lib Version: 7.2.0 App Key: g7crIrgBTsyVVlVeRDNkgQ Production: NO.
2016-08-01 21:11:16.860 ClaroEventos.iOS[700:99783] [D] +[UAirship executeUnsafeTakeOff:] [Line 213] Setting User-Agent for UA requests to Eventos 1.0 (iPhone; iPhone OS 9.3.3; UALib 7.2.0; g7crIrgBTsyVVlVeRDNkgQ; es_DO)
2016-08-01 21:11:16.898 ClaroEventos.iOS[700:99783] Channel ID: 99507222-8b57-4d0b-8662-32b302b97b63
2016-08-01 21:11:16.898 ClaroEventos.iOS[700:99783] [D] -[UANamedUser update] [Line 61] New or re-install, skipping named user update.
2016-08-01 21:11:16.944 ClaroEventos.iOS[700:99783] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: developmentAppSecret
2016-08-01 21:11:16.945 ClaroEventos.iOS[700:99783] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: detectProvisioningMode
2016-08-01 21:11:16.945 ClaroEventos.iOS[700:99783] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: developmentAppKey
2016-08-01 21:11:16.946 ClaroEventos.iOS[700:99783] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: productionAppKey
2016-08-01 21:11:16.947 ClaroEventos.iOS[700:99783] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: productionAppSecret
2016-08-01 21:11:16.948 ClaroEventos.iOS[700:99783] [I] +[UAirship executeUnsafeTakeOff:] [Line 282] Automatic setup enabled.
2016-08-01 21:11:16.948 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:handleActionWithIdentifier:forRemoteNotification:completionHandler: class AppDelegate
2016-08-01 21:11:16.951 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:completionHandler: class AppDelegate
2016-08-01 21:11:16.951 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:didReceiveRemoteNotification:fetchCompletionHandler: class AppDelegate
2016-08-01 21:11:16.952 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:didReceiveRemoteNotification: class AppDelegate
2016-08-01 21:11:16.952 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:didRegisterForRemoteNotificationsWithDeviceToken: class AppDelegate
2016-08-01 21:11:16.952 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:didRegisterUserNotificationSettings: class AppDelegate
2016-08-01 21:11:16.953 ClaroEventos.iOS[700:99783] [D] +[UAAppDelegateProxy swizzle:implementation:class:] [Line 106] Adding implementation for application:didFailToRegisterForRemoteNotificationsWithError: class AppDelegate
Resolved pending breakpoint at 'UrbanAirshipReceiver.cs:16,1' to void ClaroEventos.iOS.UrbanAirshipReceiver.ReceivedBackgroundNotification (Foundation.NSDictionary Dictionary) [0x00001].
Resolved pending breakpoint at 'UrbanAirshipReceiver.cs:13,3' to void ClaroEventos.iOS.UrbanAirshipReceiver..ctor () [0x00000].
2016-08-01 21:11:20.986 ClaroEventos.iOS[700:99783] [D] -[UAAnalytics addEvent:] [Line 252] Adding app_init event AF2068ED-B22B-4047-8DE1-9B548D27359D.
2016-08-01 21:11:21.001 ClaroEventos.iOS[700:99783] [D] -[UAPush updateRegistration] [Line 883] APNS registration is out of date, updating.
2016-08-01 21:11:21.001 ClaroEventos.iOS[700:99783] [D] -[UAPush updateAPNSRegistration] [Line 1029] Registering for user notification types 7.
2016-08-01 21:11:21.101 ClaroEventos.iOS[700:99783] [D] -[UAChannelRegistrar updateChannel:channelLocation:withPayload:] [Line 99] Updating channel 99507222-8b57-4d0b-8662-32b302b97b63
2016-08-01 21:11:21.103 ClaroEventos.iOS[700:99783] [D] -[UAInboxMessageList retrieveMessageListWithSuccessBlock:withFailureBlock:] [Line 128] Retrieving message list.
Thread started: #6
2016-08-01 21:11:21.507 ClaroEventos.iOS[700:99783] [I] -[UAPush appRegisteredUserNotificationSettings] [Line 1093] Application did register with user notification types 7.
2016-08-01 21:11:21.512 ClaroEventos.iOS[700:99783] [I] __56-[UAInboxMessageList refreshInboxWithCompletionHandler:]_block_invoke_2 [Line 389] Inbox messages updated.
2016-08-01 21:11:21.513 ClaroEventos.iOS[700:99783] [D] __56-[UAInboxMessageList refreshInboxWithCompletionHandler:]_block_invoke_2 [Line 391] Loaded saved messages: (
).
2016-08-01 21:11:21.529 ClaroEventos.iOS[700:99783] Device token: 8a1e295822fd3616a3db780370ab1ceef3caea59adb0b3c3e2c2a49ff34732ad
2016-08-01 21:11:21.530 ClaroEventos.iOS[700:99783] [I] -[UAPush appRegisteredForRemoteNotificationsWithDeviceToken:] [Line 1078] Application registered device token: 8a1e295822fd3616a3db780370ab1ceef3caea59adb0b3c3e2c2a49ff34732ad
2016-08-01 21:11:21.531 ClaroEventos.iOS[700:99783] [D] -[UAAnalytics addEvent:] [Line 252] Adding device_registration event 53241B07-84F2-4663-A427-1448FB2C1145.
2016-08-01 21:11:21.579 ClaroEventos.iOS[700:99783] [D] -[UAChannelRegistrar registerWithChannelID:channelLocation:withPayload:forcefully:] [Line 58] Ignoring registration request, one already in progress.
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
2016-08-01 21:11:22.389 ClaroEventos.iOS[700:99783] [I] __20-[UAUser updateUser]_block_invoke.148 [Line 231] Updated user 4U3MSG_0SzSs21xFBf0OWA successfully.
2016-08-01 21:11:22.393 ClaroEventos.iOS[700:99783] [D] __59-[UAInboxAPIClient retrieveMessageListOnSuccess:onFailure:]_block_invoke_3 [Line 172] Setting Last-Modified time to '(null)' for user 4U3MSG_0SzSs21xFBf0OWA's message list.
2016-08-01 21:11:22.394 ClaroEventos.iOS[700:99783] [D] __75-[UAInboxMessageList retrieveMessageListWithSuccessBlock:withFailureBlock:]_block_invoke.73 [Line 166] Refreshing message list.
2016-08-01 21:11:22.399 ClaroEventos.iOS[700:99783] [I] __56-[UAInboxMessageList refreshInboxWithCompletionHandler:]_block_invoke_2 [Line 389] Inbox messages updated.
2016-08-01 21:11:22.399 ClaroEventos.iOS[700:99783] [D] __56-[UAInboxMessageList refreshInboxWithCompletionHandler:]_block_invoke_2 [Line 391] Loaded saved messages: (
).
2016-08-01 21:11:24.386 ClaroEventos.iOS[700:99783] [I] -[UAPush registrationSucceededWithPayload:] [Line 1099] Channel registration updated successfully.
Thread finished: <Thread Pool> #4
2016-08-01 21:11:37.293 ClaroEventos.iOS[700:99783] [D] __41-[UAAnalytics uploadOperationWithEvents:]_block_invoke [Line 537] Analytics data sent successfully. Status: 200
2016-08-01 21:11:46.329 ClaroEventos.iOS[700:99783] [I] -[UAPush appReceivedRemoteNotification:applicationState:fetchCompletionHandler:] [Line 603] Application received remote notification: {
"_" = "FBolUFhOEeaYn5DiugL0-A";
aps = {
alert = "this is an example for urbanairship";
};
}
2016-08-01 21:11:46.330 ClaroEventos.iOS[700:99783] [D] -[UAAnalytics addEvent:] [Line 252] Adding push_received event 318158FA-8D9F-43A5-B5BA-616F814C7A52.
2016-08-01 21:11:46.337 ClaroEventos.iOS[700:99783] [D] +[UAActionRunner runActionWithName:value:situation:metadata:completionHandler:] [Line 84] No action found with name aps, skipping action.
2016-08-01 21:11:46.338 ClaroEventos.iOS[700:99783] [D] +[UAActionRunner runActionWithName:value:situation:metadata:completionHandler:] [Line 84] No action found with name _, skipping action.
2016-08-01 21:11:46.338 ClaroEventos.iOS[700:99783] [D] __47-[UAAction runWithArguments:completionHandler:]_block_invoke_3 [Line 71] Action <UAIncomingPushAction: 0x155e3120> performing with arguments UAActionArguments with situation: Foreground Push, value: {
"_" = "FBolUFhOEeaYn5DiugL0-A";
aps = {
alert = "this is an example for urbanairship";
};
}.
2016-08-01 21:11:46.338 ClaroEventos.iOS[700:99783] [W] -[UAIncomingPushAction handleForegroundPush:completionHandler:] [Line 80] Recieved a foreground push notification when the [UAirship push].pushNotificationDelegate is not set. Unable to show any UI.
Thread finished: <Thread Pool> #5
Thread finished: <Thread Pool> #8
Thread finished: <Thread Pool> #3

 

this is the AppDelegate

using Foundation;
using UIKit;
using UrbanAirship;

namespace ClaroEventos.iOS
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init ();
            ClaroEventos.App.TodoCalendar = new TodoItemCalendar (Reminder.Default);
            ClaroEventos.App.TodoManager = new TodoItemManager (ParseStorage.Default);
            UIButton.Appearance.TintColor = UIColor.LightGray;
            UIButton.Appearance.SetTitleColor(UIColor.FromRGB(219, 32, 34), UIControlState.Normal);
            LoadApplication (new ClaroEventos.App ());
                UAirship.TakeOff ();

                UAirship.Push.UserPushNotificationsEnabled = true;
                UITabBar.Appearance.SelectedImageTintColor = UIColor.FromRGB(221,34,36);
                 UAirship.Push.PushNotificationDelegate = new UrbanAirshipReceiver();


            return base.FinishedLaunching (app, options);
        }
    }
}
this is my delegate

using System;
using Foundation;
using UIKit;
using UrbanAirship;

namespace ClaroEventos.iOS
{
    public class UrbanAirshipReceiver : UAPushNotificationDelegate
    {

    
        private NotificationsDatabase database = TabPage.Database;
        public override void ReceivedBackgroundNotification(NSDictionary Dictionary)
        {
            NSDictionary aps = Dictionary.ObjectForKey(new NSString("aps")) as NSDictionary;
            string alert = string.Empty;
            string badge = string.Empty;

            if (aps.ContainsKey(new NSString("alert")))
                alert = (aps[new NSString("alert")] as NSString).ToString();

            if (aps.ContainsKey(new NSString("badge")))
                badge = (aps[new NSString("badge")] as NSString).ToString();


            int notificationID = Convert.ToInt16(badge);

            var NewNotification = new NotificationMessage(notificationID,alert,true,DateTime.Now);
            database.AddNotification(NewNotification);

        }
        public override void ReceivedForegroundNotification(NSDictionary Dictionary)
        {
            NSDictionary aps = Dictionary.ObjectForKey(new NSString("aps")) as NSDictionary;
            string alert = string.Empty;
            string badge = string.Empty;

            if (aps.ContainsKey(new NSString("alert")))
                alert = (aps[new NSString("alert")] as NSString).ToString();
            
            if (aps.ContainsKey(new NSString("badge")))
                badge = (aps[new NSString("badge")] as NSString).ToString();
        
            int notificationId = Convert.ToInt16(badge);


            var NewNotification = new NotificationMessage(
                notificationId,
                alert,
                true,
                DateTime.Now
            );



            database.AddNotification(NewNotification);
        
        }


    }
}

Didn't find what you were looking for?

New post

Comments

0 comments

Please sign in to leave a comment.