iPHONE Push...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ace16vitamine
Posts: 130
Joined: Fri Apr 13, 2018 1:53 pm

iPHONE Push...

Post by ace16vitamine » Wed Jul 29, 2020 2:40 pm

Dear all,

I have a simple problem with creating Push apps.

I have started with this lesson:
http://lessons.livecode.com/m/4069/l/53 ... s-with-ios

Certification is done, it is in the provisioning profile and I have checked it in the console. I also have the device ID.

But if I try to send notifications (e.g.:) i didn't receive any message on my iPhone:

Code: Select all

cat Notification.bin | openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushNotificationAppCertificate.pem -key PushNotificationAppKey.pem
Same with gateway.push.apple.com. Can it be that I need a production certificate also for testflight apps? Or is there any other sample stack (livecode-server welcome) available?

THanks
Stefan

ace16vitamine
Posts: 130
Joined: Fri Apr 13, 2018 1:53 pm

Re: iPHONE Push...

Post by ace16vitamine » Wed Jul 29, 2020 2:43 pm

Here is the code to generate the notification

Code: Select all

on mouseup
   # Provide the Host Information.
   local tHost = "gateway.sandbox.push.apple.com"
   local tPort = 2195
   local tCert = "/Users/test/Desktop/PushApp/PushNotificationAppCertificateKey.pem"
   local tPassphrase = "XXX"
   local tToken = "08fe376bc22b976057896bf1a99e8ff9b59f46187fe57360fdXXXXXXXXXXX"
   local tAlert = "You have a LiveCode APNS Message"
   local tBadge = 8;
   # Audible Notification Option.
   local tSound = "default"
   # The content that is returned by the LiveCode "pushNotificationReceived" message.
   local tPayload = "APNS Message Handled by LiveCode"
   # The target folder. Ensure this folder contains all the certificates and keys needed
   local tFolder = "/Users/test/Desktop/PushApp"
   # Keep note of the current folder.
   local tSavedFolder
   put the defaultFolder into tSavedFolder
   set the defaultFolder to tFolder
   # Create the notification.
   local tBody
   put tAlert into tBody["aps"]["alert"]
   put tBadge into tBody["aps"]["badge"]
   put tSound into tBody["aps"]["sound"]
   put tPayload into tBody["payload"]
   local tNotification
   put arrayToJson(tBody) into tNotification
   
   # Build the binary notification to send.
   local tBinary
   put empty into tBinary
   repeat for each item tCode in "0,0,32"
      put numToChar(tCode) after tBinary
   end repeat
   put binaryEncode("H*", tToken) after tBinary
   put binaryEncode("n", length(tNotification)) after tBinary
   put tNotification after tBinary
   # Write the binary to a file and send via openssl
   put tBinary into URL("binfile:Notification.bin")
   get shell("cat Notification.bin | openssl s_client -connect" && tHost & ":" & \
         tPort && "-cert" && tCert && "-pass pass:" & tPassphrase)
   
   answer "Result after attempting to send notification to server:" & LF & LF & it
   set the defaultFolder to tSavedFolder
end mouseup

ace16vitamine
Posts: 130
Joined: Fri Apr 13, 2018 1:53 pm

Re: iPHONE Push...

Post by ace16vitamine » Wed Jul 29, 2020 3:46 pm

I found the issue. For the documentation:

To test push messages with Testflight you need a production certificate :roll:

Post Reply

Return to “iOS Deployment”