The index.html
file containing JavaScript that makes use of the
LocalNotifications API functionality is listed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <!DOCTYPE html> <html manifest= "manifest.appcache" > <head> <title>LocalNotification example</title> <link rel= "x-antenna-managed-webapp-descriptor" href= "webapp-descriptor.xml" /> <script type= "text/javascript" > function schedule() { var notification = { fireDate: new Date(), title: document.getElementById( "title" ).value, message: document.getElementById( "message" ).value, badge: document.getElementById( "badge" ).value, repeatInterval: window.launchbox.LocalNotifications.MINUTE_INTERVAL }; launchbox.LocalNotifications.schedule(notification); } function cancel() { launchbox.LocalNotifications.cancelAll(); } function shutdown() { launchbox.Container.shutdown(); //lifecycle method } </script> </head> <body> <header> <h3><span>LocalNotification API usage example</span> </h3> </header> <div class= "white_box_content" style= "height: auto;" > <div> <input type= "text" id= "title" value= "Local notification" /> <input type= "text" id= "message" value= "Default message" /> <input type= "text" id= "badge" value= "1" /> </div> <div> <input type= "button" onclick= "schedule();" value= "Schedule a notification" /> <input type= "button" onclick= "cancel();" value= "Cancel all pending notifications." /> <input type= "button" onclick= "shutdown();" value= "Shutdown container" /> </div> </div> <div id= "text-box" ></div> </body> </html> |
The contents of the cache manifest file called manifest.appcache
for
this application are listed below:
1 2 3 4 5 6 7 | CACHE MANIFEST CACHE: index.html NETWORK: * |
The webapp-descriptor.xml
file for this application is defined in the
following way:
1 2 3 4 5 6 7 | <? xml version = "1.0" encoding = "UTF-8" ?> < webapp-descriptor xmlns="http://www.pega.com/application-hosting/ web-app-descriptor/2.0"> < id >com.pega.sample.LocalNotifications</ id > < version >1.0.0</ version > < name >LocalNotifications API usage example</ name > </ webapp-descriptor > |