Archive for the ‘Delphi’ Category
I was recently in a situation where I had access to only port 80.
This means that RDP (port 3389) doesn’t work… Amazon EC2 APNS demo was out.
Even local APNS was out, because it uses port 2195 from the sending server…
So, I decided to retrofit my APNS server and make it a DataSnap server responding to port 80 in addition to being a client I can click a button on using RDN to Amazon EC2.
I created a server method SendPushNotification. It takes the DeviceToken and the text message as parameters.
I call it from any browser anywhere on the following URL scheme:
And it works! So next time I’m locked down to port 80 my demos will work just fine…
Sometimes I’m easily amused!
Since I’m using a third party component for In-App Purchasing, I’m not sure where this bug is, but it seems that SKRequest.start crashes when there is no connectivity to the Internet in general (or to the AppStore in particular).
My solution is to check for reachability to the AppStore, because that’s what we really care about. I’m using Indy for a multi-platform solution (as opposed to iOS APIs).
I offer the following code up as a solution. Tear it apart…
uses ..., IdComponent, IdTCPClient; type TForm2 = class(TForm) ... public Conn : TIdTCPClient; procedure TCPClientStatus(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string); procedure TCPClientConnected(Sender: TObject); procedure TCPClientDisconnected(Sender: TObject); end; implementation procedure TForm2.Button1Click(Sender: TObject); begin // Attempt to connect to the AppStore Conn := TIdTCPClient.Create(nil); Conn.Host := 'itunes.apple.com'; Conn.Port := 80; Conn.OnConnected := TCPClientConnected; Conn.OnDisconnected := TCPClientDisconnected; Conn.OnStatus := TCPClientStatus; try Conn.Connect; except ; // Failure - No Internet Connection end; end; procedure TForm2.TCPClientConnected(Sender: TObject); begin // Disconnect gracefully Conn.Disconnect; end; procedure TForm2.TCPClientDisconnected(Sender: TObject); begin // No need for this TCP client anymore Conn.DisposeOf; end; procedure TForm2.TCPClientStatus(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string); begin if Pos('Connecting to',AStatusText) > 0 then // We have reachability to the AppStore, so go ahead and call LoadProducts InAppPurchase1.LoadProducts; end;
Less than 48 hours from submission to approval is spectacular!
I’m feeling like a kid in a candy story when I get new stuff into the AppStore!
Nothing like a little Candy Crush Saga while watching the time fly away as you develope super cool FireMonkey apps for iOS using Delphi XE4!
Simon Choi has a beta version of his iAd wrapper for Delphi XE4 for iOS.
Very cool. I decided to take it for a spin, and it works in development mode on my device.
As a final test, I submitted an update of my Analog Clock app. If you’re one of 1,900 people who have tried it, you should see the update (if approved) soon.
A little bit of clarification on my APNS blog post(s) comment threads…
Deployment tab - notice IDE maintained file UNCHECKED - your file - CHECKED - remote name - Entitlements.plist:
Provisioning tab (specify the first two, hit Load ID):
Version Info tab:
<?xml version="1.0" encoding="UTF-8"?> <plist version="1.0"> <dict> <key>application-identifier</key> <string>XZ9AC2Q82Q.com.AndersOhlsson.FMX.01</string> <key>aps-environment</key> <string>development</string> <key>get-task-allow</key> <true/> </dict> </plist>