Platforms to show: All Mac Windows Linux Cross-Platform

/MacCloud/Push Notification/Push Notification
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCloud/Push Notification/Push Notification
This example is the version from Sun, 17th Mar 2012.
Project "Push Notification.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() a = new MyNSApplicationDelegateMBS NSApplicationMBS.sharedApplication.registerForRemoteNotificationTypes NSApplicationMBS.NSRemoteNotificationTypeBadge End EventHandler
Property a As MyNSApplicationDelegateMBS
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSApplicationDelegateMBS Inherits NSApplicationDelegateMBS
EventHandler Sub applicationDidFailToRegisterForRemoteNotificationsWithError(error as NSErrorMBS) MainWindow.List.AddRow "Failed to register for remote notifications: "+error.localizedDescription End EventHandler
EventHandler Sub applicationDidFinishLaunching(Notification as NSNotificationMBS) dim userinfo as Dictionary = Notification.userInfo 'Notification.print dim d as Dictionary = userinfo.Lookup(NSApplicationMBS.NSApplicationLaunchRemoteNotificationKey ,nil) if d<>nil then dim s as string dim badge as string if d<>Nil then s = d.Lookup("alert", "?") badge = d.Lookup("badge", "?") end if MainWindow.List.AddRow "Received Notification for Launch: """+s+""" and badge "+badge else MainWindow.List.AddRow "Launched." end if End EventHandler
EventHandler Sub applicationDidReceiveRemoteNotification(userInfo as Dictionary) dim d as Dictionary = userInfo.Lookup("aps", nil) dim s as string dim badge as string if d<>Nil then s = d.Lookup("alert", "?") badge = d.Lookup("badge", "?") end if MainWindow.List.AddRow "Received Notification """+s+""" and badge "+badge End EventHandler
EventHandler Sub applicationDidRegisterForRemoteNotificationsWithDeviceToken(deviceToken as memoryblock) MainWindow.List.AddRow "Registered for Remote Notifications: "+EncodeHex(deviceToken) End EventHandler
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCloud Plugin.

The biggest plugin in space...




Links
MBS Xojo PDF Plugins

Start Chat