Announcement

Collapse
No announcement yet.

Push Notification

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Push Notification

    Can anyone provide some sample code showing how to do push notification?

    I tried several examples but couldn't get it to work?

    Is there some modifications to config files needed to get local push notification working?

    #2
    Post the code you have written and at every line explain what you expected and what was the value on the device e.g does class'PlatformInterfaceBase'.static.GetAppNotifica tionsInterface(); return null
    You can also check the push notifications are enable in iTunes connect
    This has being asked before and working example can be found using search

    Comment


      #3
      Do I need to enable push notification in iTunes connect, even for local notifications?

      Comment


        #4
        Yes because the os will need to know that the app will use push notifications http://developer.apple.com/library/I...uid/TP40008194

        Comment


          #5
          I have enabled push notifications in the AppID. I haven't generated Apple Push Notification service SSL Certificates because I am testing local notification now.

          Click image for larger version

Name:	appid.jpg
Views:	1
Size:	46.9 KB
ID:	3249830

          I am using your sample code to generate the notification.

          Code:
          exec function appno() 
          { 
          	local string a; 
          	local AppNotificationsBase b; 
          	local NotificationInfo c; 
          	local NotificationMessageInfo d; 
          
          	
          
              if (class'engine'.static.HasNetworkConnection()) 
              { 
          		PrintText("Has internet");
          
                      a = class'engine'.static.GetDevicePushNotificationToken();// clasified by udn 
                      b = class'PlatformInterfaceBase'.static.GetAppNotificationsInterface();// clasified by udn 
          			//b.AddDelegate(0,OnReceivedLocalNotification);
                      d.Key = "1"; 
                      d.Value = "win"; 
                      c.BadgeNumber = 1; 
                      c.bIsLocal = true; 
                      c.MessageBody = "please come back on my app"; 
                      c.MessageInfo.AddItem(d); 
                      b.ScheduleLocalNotification(c,12);// so where do remote notification come in 
                      b.DebugLogNotification(c); // the info should be in the logfile now just to test 
          
          			PrintText("Message sent");
              } 
          }
          I can see my 2 debug texts on the screen but I don't get the notification.
          Any idea what I did wrong?

          Comment


            #6
            I noticed that when I installed the app in iPad the app is not listed in the Notifications section of the settings.
            But if I enabled the notifications why does it happen that way?

            Comment


              #7
              Ok, I found part of the problem.
              In \Engine\Config\IPhone\IPhoneEngine.ini I have to set bSupportsPushNotifications=True

              Zeqzy, I don't know how you found this because I can't find any documentation on this !
              Now my app get listed in the notification section of settings

              But still noting get displayed ...

              Can anyone help me on this?

              Comment


                #8
                Do I have to minimize or exit the game to receive the local notification ?

                Comment


                  #9
                  No however notifications are time based so c is the message and the 12 is seconds
                  Based on your example c is not going to work because it is not a const

                  Comment


                    #10
                    Zeqzy, I am really confuse how to do this.

                    As I understand the only way for me to make c const and set its values is to do it in DefaultProperties, so this is what I have done,

                    Code:
                    class PushNotificationGame extends FrameworkGame;
                    
                    
                    var const NotificationInfo noticeInfo;
                    var const NotificationMessageInfo MessageInfo;
                    
                    exec function pt() 
                    {
                    	local string tokenLine; 
                    	local AppNotificationsBase appNotifyInterface;
                    
                    
                    	tokenLine = class'engine'.static.GetDevicePushNotificationToken();
                    
                    	appNotifyInterface = class'PlatformInterfaceBase'.static.GetAppNotificationsInterface();
                    
                    	if (appNotifyInterface != none)
                    	{
                    
                    		appNotifyInterface.OnReceivedLocalNotification = OnReceivedLocalNotification;
                    		appNotifyInterface.ScheduleLocalNotification(noticeInfo,15);
                    	}
                    	
                    }
                    
                    
                    DefaultProperties
                    {
                    
                    
                    	MessageInfo={(Key="1",Value="win")}
                    
                    		noticeInfo={(
                    			BadgeNumber=1,
                    			MessageBody="please come back on my app",
                    			bIsLocal=true,
                    			)}
                    
                    	noticeInfo=(MessageInfo[0]=MessageInfo)
                    }
                    I still not seeing the notice

                    If I do it this way the values are also fixed. I won't be able to raise different push notifications in the game.

                    Is it possible for you to post some code that you got to work?

                    Comment


                      #11
                      bump ... i have this question yet ... need guys help.

                      Comment


                        #12
                        You don't need to use the default properties you can get the info from the ini file
                        Check that the app is setup correctly in iTunes connect
                        Check that scripts are being rebuilt when you test it on the iOS device
                        Check that appnotificationbase is initialised
                        Check that NotificationInfo and NotificationMessageInfo are const
                        Check the documentation on udn for examples
                        Check the app is not running when the notification is received
                        If you still have problems use the debuglocalnotification to see what may be causing the error
                        Here is an example of push notifications
                        PHP Code:
                        var string message;
                        var 
                        string message1;

                        exec function OnMultiLineInput(optional string a)
                        {
                                
                        message a;
                        }

                        exec function OnLineInput(optional string a)
                        {
                                
                        message1 a;
                        }

                        exec function test()
                        {
                                
                        local NotificationMessageInfo c;
                                
                        local AppNotificationsBase A;
                                
                        local NotificationInfo b;
                                
                        local string D;
                                
                        message"";
                                
                        message1"";
                                
                        "mobile GetUserInputMulti test null OnMultiLineInput";
                                
                        ConsoleCommand(D);
                                
                        c.Key message;
                                
                        c.Value "1";
                                
                        = class'PlatformInterfaceBase'.static.GetAppNotificationsInterface();
                                if(
                        != none)
                                {
                                                
                        b.BadgeNumber 1;
                                                
                        b.MessageBody message1;
                                                
                        "mobile GetUserInput test null OnLineInput ";
                                                
                        ConsoleCommand(D);
                                                
                        A.ScheduleLocalNotification(b90);
                                }

                        Edit:
                        If you want to use the 2 delegates that are available try
                        PHP Code:
                        local AppNotificationsBase A;
                        = class'PlatformInterfaceBase'.static.GetAppNotificationsInterface();
                        A.__OnReceivedLocalNotification__Delegate Localping;
                        function 
                        Localping(const out NotificationInfo Notificationbool bWasAppActive
                        Also you can try this function
                        PHP Code:
                        function Sendnotification(string text, const NotificationMessageInfo MessageInfo)
                        {
                                
                        local AppNotificationsBase A;
                                
                        local NotificationInfo b;
                                
                        = class'PlatformInterfaceBase'.static.GetAppNotificationsInterface();
                                if(
                        != none)
                                {
                                                
                        b.BadgeNumber 1;
                                                
                        b.MessageBody text
                                                
                        b.MessageInfo.AddItem(MessageInfo);
                                                
                        A.ScheduleLocalNotification(b90);
                                }

                        Comment


                          #13
                          hi wijesijp, do you make the push notification work now ,i test Zeqzy's method , but can't work still.

                          bump....

                          Comment

                          Working...
                          X