In-App Purchase: SKRequest.start bug?
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;

Comments
-
olecramoak Wednesday, 26 June 2013
hello Anders! Why 3rd party and not direct head parsing with phil hess tools? Currently, I know two apps live on Appstore developed with firemonkey that use Storekit smoothly (there even is a function for testing store reachability)...maybe a more direct approach would be more efficient.
-
I don't think start is the cause of the exception. You should find that request:didFailWithError: gets called if there is no connectivity.
Granted it gets called with a useless empty error object, but it gets called nevertheless.
The question is whether the 3rd party code catches that delegate method, and maybe whether it assumes there is something useful in the error object, checks for nil etc. -
Tom Marchione Sunday, 15 September 2013
Has anyone successfully installed the IAP component in XE5? I am having difficulty. Offhand, it appears that XE5 includes some sort of StoreKit support that was not in XE4, and requires implentation of a certain interface method called "paymentQueueUpdatedDownloads". Am I seeing things? Has anyone made this work in XE5 yet?
-
Tom Marchione Sunday, 15 September 2013
To follow up on my last comment, if you remove the reference to StoreKit in the IAP package, and implement "paymentQueueUpdatedDownloads" and "paymentQueueUpdatedTransactions" in FMX.IAP.IOS, the component will compile and install in XE5. However, I am not familiar with the internals of StoreKit, so I am not entirely sure what the above methods should do.
-
Tom Marchione Monday, 16 September 2013
One more follow-up... I contacted the IAP developer (who is extremely responsive, BTW -- a pleasure to deal with). He confirmed that XE5 has an incomplete implementation of StoreKit in the RTL, which is conflicting with his component. He created a workaround by renaming one of his units, which removes the conflict and allows the component's StoreKit implementation to coexist peacefully with the incomplete references in the XE5 RTL. Problem solved. That said, I don't know if the methods that are not implemented in his component but are required in the native XE5 interface are worth investigating someday. For now, I am mainly interested in moving my development to XE5, so that I can sunset XE4. And this seems to accomplish that.
-
Please login first in order for you to submit comments
- Page :
- 1
Hi,Anders, Could you share the third party component or the links of it?