What is the FBSDKPaymentObserver doing? And how do I disable it? - ios

I am currently having issues with my SKPaymentQueue and the observer, right now I cannot say exactly what the issue is, but it is not working.
When debugging I have noticed that my default SKPaymentQueue has multiple observers added to it, one being the class FBSDKPaymentObserver and it is listening to - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions. The thing is that it is working perfectly and observing all failed transactions.
Why does the FB-SDK do that?
How do i disable that?

Actually a pretty simple answer. I had forgotten I had set [FBSDKAppEvents activateApp];.
This sets a SKPaymentObserver at app startup which "swallows" the events which means that your own app observer does not get the messages from Apple with the same timing. Facebook gets it first and I am not sure how long after it will be sent by apple again.

Related

iOS CallKit - no 'missed call notifications'

I am using CallKit, and it is working fine, it calls on my phone properly, I can answer and deny it.
The problem is there is no 'missed call' notification when I do not answer it.
Is there any setting in CallKit that toggles it?
We were also facing the same issues, and the solution was to manage UILocalNotifications yourself. CallKit only provides triggers and callbacks for events.
Check out the method reportCall(with:endedAt:reason) on CXProvider. You can specify the end reason to let CallKit know why the call ended.
https://developer.apple.com/documentation/callkit/cxprovider/1930701-reportcall
The reasons include:
case failed - An error occurred while attempting to service the call.
case remoteEnded - The remote party explicitly ended the call.
case unanswered - The call never started connecting and was never
explicitly ended, such as when an outgoing or incoming call times
out.
case answeredElsewhere - Another device answered the call.
case declinedElsewhere - Another device declined the call.
If you call reportCall with a reason of unanswered, then it will show up as a missed call in the recent calls section of the phone app.

SKPaymentQueue Transaction issues iOS

I have been testing In App Purchases and can only assume that there are transactions stuck in the queue.
I have called [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; but every time I start the app it asks me to login to iTunes.
I have checked within -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{ but even if I place an NSLog in the first line, this is NOT being called. Thus I don't believe this is being called.
I have also called NSLog(#"PAYMENTQUEUE:%#",[[SKPaymentQueue defaultQueue] transactions]); which shows null.
Can someone advise why I would constantly be asked to login to iTunes every time I start the app all of a sudden? As I say, I can only assume it is a transaction, but how can I track it down?
Your device has been infected with the "endless loop" for failing to have called finishTransaction. It will reoccur every week like clockwork. Check out the IAP Developer's Forum for more info. The queue is empty because you need to log in as the 'infected' user.
Just in case anyone comes across this later on with the same issue. I left the device and stopped trying to sort it out. I deleted the app too.
Around half an hour later I was prompted to logon to the iTunes sandbox store (remember there was no app on anymore).
I logged in, and this scenario occurred another time.
After that all seemed to go quiet.
I have tried installing the app again today (12 hours later) and the issue has gone away.
I can only assume something got jammed up?

My ios application is always asking me to Sign In to iTunes Store

I'm developing an ios Application with IAP feature. It works well. But I encountered a strange issue today. It always show me a message to ask me to "Sign In to iTunes Store" for some reasons. Here is the screenshot:
It always shows this every time when I start the application or resume from background. It even still shows this after I delete and reinstall the application. When I setup breakpoints in my source code. There is no any transaction,payment delegate callbacks. Can anybody tell me what the reason is ? Could it be the problem of Apple IAP Sandbox? (I run the same application in other devices without any problem. I can purchase, restore in Sandbox.)
I've had this problem too a couple of times, it turned out I was stopping processing of transactions before calling finishTransaction on all queued transactions. I was forgetting to finish failed transactions in the particular case.
So, you could try letting your application run once and call finishTransaction for each and every one in your observer delegate like this:
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
foreach(SKPaymentTransaction *tr in transactions) [queue finishTransaction:tr];
}
i.e. finish every transaction irrespective of transaction state.
After the test run revert to your original handling code.
Hope this helps.
I tried multiple things :
call finishTransaction for all queued transactions as explained by mpramat (in my case, the array was empty)
Reboot the iDevice
Delete the test account in iTunes Connect.
Finally, the only thing that surprisingly worked for me was to delete the app in the iDevice then re-install it via XCode.

iOS StoreKit - simulating incomplete and interrupted in-app purchases

I have an issue with a live app where incomplete purchases are being mishandled. I am trying to test my new code to make sure that this will be taken care of, so I download the live app, cause the problem, then load my development app (or Ad-Hoc app) hoping that the StoreKit Observer will catch the incomplete purchase notification. No matter how I do this (development or Ad-Hoc) the observer does not fire a notification.
My general question is: How can I simulate incomplete and interrupted purchases in the App Store testing environment?
My more specific question is: Can I simulate the specific issue where the user must leave the app to confirm their current credit card pin number on the app store?
According to this helpful page:
Test an Interrupted Transaction
Set a breakpoint in your transaction queue observer’s
paymentQueue:updatedTransactions: method so you can control whether it
delivers the product. Then make a purchase as usual in the test
environment, and use the breakpoint to temporarily ignore the
transaction—for example, by returning from the method immediately
using the thread return command in LLDB. Terminate and relaunch your
app. Store Kit calls the paymentQueue:updatedTransactions: method
again shortly after launch; this time, let your app respond normally.
Verify that your app correctly delivers the product and completes the
transaction.
Hope this helps someone.
To your general question:
SKPaymentTransaction provides several transaction states like SKPaymentTransactionStateFailed
According to the Documentation you can check out the error property to see what happened.
For example you can check it in -(void)paymentQueue:(SKPaymentQueue *)updatedTransactions:(NSArray *)transactions callback like so
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction * transaction in transactions) {
switch (transaction.transactionState)
{
case SKPaymentTransactionStateFailed:
...
break;
default:
break;
}
};
}
Hope this helps.

Downloading content from Apple hosted in-app purchase

I have an in-app purchase which is Apple hosted. However I can't figure out how to download the content associated with it.
I could get the downloadable objects and request the download start:
[[SKPaymentQueue defaultQueue] startDownloads:currentTransaction.downloads];
that's when I get lost: what should I do after that?
I have taken a look at Apple doc and didn't find anything that could possibly help me.
Thx
Implement an SKPaymentTransactionObserver. The observer will be notified when the payment queue changes status. For example, paymentQueue:updatedDownloads: will be called with an array of SKDownloads whose downloadState indicates the status change for a download. If you want to know about completed downloads, look for downloadState == SKDownloadStateFinished.
See http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKPaymentTransactionObserver_Protocol/Reference/Reference.html
I could solve my problem. Calling the
[[SKPaymentQueue defaultQueue] startDownloads:currentTransaction.downloads];
then
(void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads
is constantly called back. I guess I had forgotten some delegates or something like that. Besides that, I deleted the app from my device and re-compiled it again from Xcode. Then it worked like a charm =) Thanks

Resources