Anyone using Livecode Server for sending PushNotifications?

Matthias Rebbe | M-R-D matthias_livecode_150811 at m-r-d.de
Thu Sep 25 16:26:18 EDT 2014


Jim,

thanks for that.

Matthias


Am 25.09.2014 um 19:29 schrieb Jim Lambert <jiml at netrin.com>:

> 
> About a year ago I used John’s lcx files for doing push notifications and they worked beautifully.
> 
> If you only need to send a single notification to a single device here’s a variation on John’s script that will do it.
> 
> Jim Lambert
> 
> <?lc
> include "includes/json.lc"
> 
> command sendNotification pDevice, pAlert, pBadge, pSound, pPayload
> # Provide the Host Information.
> local tHost = "gateway.sandbox.push.apple.com"
> local tPort = 2195
> 
> # Provide the Certificate and Key Data.
> local tCert = "AppCertKey.pem"
> 
> # Provide the Private Key Passphrase (alternatively you can keep this secrete and 
> # enter the key manually on the terminal -> remove relevant line from code).
> # Replace XXXXX with your Passphrase
> local tPassphrase = "XXXXX"
> 
> 	# create the notificaion
> 	put pAlert into tBodyA["aps"]["alert"]
> 	put pBadge into tBodyA["aps"]["badge"]
> 	put pSound into tBodyA["aps"]["sound"]
> 	put pPayload into tBodyA["payload"]
> 
> 	# convert to json - Mark Smith's library
> 	put arrayToJson(tBodyA) into tNotification
> 
> 	# build the binary notification to send
> 		repeat for each item tCode in "0,0,32"
> 			put numToChar(tCode) after tBinary
> 		end repeat
> 		put binaryEncode("H*", tDevice) after tBinary
> 		put binaryEncode("n", length(tNotification)) after tBinary
> 		put tNotification after tBinary
> 
> 	# write the binary to a file and send via openssl
> 	put (pDevice & the seconds) & ".bin" into tFile
> 	put tBinary into URL("binfile:APNs/" & tFile)
> 	get shell("cat APNs/" & tFile & " | openssl s_client -connect" && tHost & ":" &  tPort && "-cert" && tCert && "-pass pass:" & tPassphrase)
> 	
> end sendNotification
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode








More information about the use-livecode mailing list