presentCodeRedemptionSheet() is not working - ios

I am creating offer codes with auto-renewable In-app purchases in swift. But when i use presentCodeRedemptionSheet(), it does not show any redemption page to redeem offer code. I am using below code, but nothing is happening on tapping the button.
let paymentQueue = SKPaymentQueue.default()
if #available(iOS 14.0, *) {
DispatchQueue.main.async {
paymentQueue.presentCodeRedemptionSheet()
}
}

Are you trying on the simulator?
This command only works on a real device not in the simulator.

Related

Is Sign in with Apple (SIWA) supported in the tvOS simulator?

I have enabled the entitlements for SIWA in the project target. And the same steps are working fine in the iOS simulator.
I am facing the following issue while trying to Sign in with Apple (SIWA) on the tvOS simulator.
Steps to reproduce the issue:
Upon requesting for SIWA on custom button tap, a full-screen layover displayed for the password of apple id (No option for choosing email relay was given) (screenshot attached in the last for reference)
Upon entering the correct password I get the callback in the error delegate.
Error in the error delegate:
error Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)"
Below is the code-snippet attached for the whole process.
I have done all the steps required as per the official document of SIWA for iOS.
FYI: The same code is working for iOS for me but not for the tvOS. I have tested SIWA in the iPhone simulator while development and now trying the same with the tvOS but it isn't working.
Below is my code.
Here, function setup( ) is called on viewDidLoad of ViewController
private func setup() {
if #available(tvOS 13.0, *) {
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: "myapp.identifiers.currentUserIdentifier") { (credential, error) in
switch credential {
case .authorized:
print("authorized for sign in")
break
case .notFound, .revoked, .transferred:
print("ready to logout")
break
default:
print("Apple sign in credential state unidentified")
}
}
}
}
Inside the action method of the custom SIWA button, my code looks like
if #available(tvOS 13.0, *) {
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.delegate = self
authorizationController.presentationContextProvider = self
authorizationController.performRequests()
}
The presentation anchor is set in the extension of ViewController
extension ENWelcomeScreenViewController: ASAuthorizationControllerPresentationContextProviding {
#available(tvOS 13.0, *)
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
return self.view.window!
}
}
And finally, the error delegate, in which I am receiving the callback.
/// - Tag: did_complete_error
#available(tvOS 13.0, *)
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
print("error \(error)")
}
Here is how it looks when the user taps on SIWA button.
Any leads are highly appreciated.
The answer to my question is a big no!!
FINDINGS:
We can not test the sign in with apple in the tvOS simulator.
When I tried running the same on Apple TV it worked.
After entering the apple id credentials to sign-in in my app I get the push notification on the device I am signed-in with the same apple id.
Nothing happens when you tap on the received push notification.
On the Apple forum, I get a similar response from their engineering team.
Here is a screen capture of Apple TV.
Just had the same issue. The simple solution is to take the term "nearby" more than literally. Hold your phone really close to the Apple TV when tapping the notification and everything will do its magic.

Siri shortcuts work on iPhone, but not on HomePod

I’m working on app that uses Siri Shortcuts, and I’ve met one strange issue:
If I run a shortcut on iPhone, it works well. If I do the same with HomePod, connected to the same iPhone, I get “There is a problem with your app” from Siri. My shortcuts are created within the app.
if #available(iOS 12.0, *) {
let activity = NSUserActivity(activityType: command.rawValue)
activity.title = selectTitle(activityType: command)
activity.isEligibleForSearch = true
activity.isEligibleForPrediction = true
activity.persistentIdentifier = NSUserActivityPersistentIdentifier(command.rawValue)
responder.userActivity = activity
activity.becomeCurrent()
}
Any ideas how to make them work via HomePod?
Thanks in advance!

Unable to get INSendPaymentIntent work with SiriKit on watchOS (3.2 and 4)

I need to finish watchOS sirikit payment app (as a companion app for the iPhone app obviously).
The same framework, logic for intent and handler are working on iOS.
I developed the intent and handler. When I ask Siri the below sentence,
using MyApp send Albert $40
Siri replies...
Sorry I can't do that. and give a button Open MyApp
I saw some posts saying Payment Intent for Siri is not available on watchOS. But I see this in SDK.
Please give pointers.
#available(watchOS 3.2, *)
open class INSendPaymentIntent : INIntent {
public init(payee: INPerson?, currencyAmount: INCurrencyAmount?, note: String?)
#NSCopying open var payee: INPerson? { get }
#NSCopying open var currencyAmount: INCurrencyAmount? { get }
open var note: String? { get }
}
The Plists and projects have right permissions and capabilities.
Payment Intent Plist has the below keys.
Image Link for Plist Keys for Payment Intent
// WatchIntentsExtension.swift
import Intents
import PaymentsFrameworkWatchOS
class WatchIntentsExtension: INExtension {
let paymentProvider = PaymentProvider()
let contactLookup = ContactLookup()
override func handler(for intent: INIntent) -> Any? {
print("Watch Overriding")
guard intent is INSendPaymentIntent else { fatalError("Unhandled intent type \(intent)") }
return WatchSendPaymentIntentHandler(paymentProvider: paymentProvider, contactLookup: contactLookup)
}
}
I cannot post code for Handler as I have compliance issues. And... I do not do much on there.
The same code works for iPhone Siri though.

In-app Purchases from iMessage app extension

I created an app that uses in-app purchases, I already have set up the in-app purchases on iTunes and I even tested it using a sandbox user and all of this is working perfectly.
now that I included an iMessage app extension, the same in-app purchase products return invalidProduct Id, but continues working well inside the main app.
could be because the bundle id?
mainapp: com.whatever.bundleid
app iMessage: com.whatever.bundleid.iMessage
iMessage extension: com.whatever.bundleid.iMessage.MessagesExtension
btw, i'm using the SwiftyStoreKit pod.
if let inappIndentifier = stickerPackage.inAppPurchaseId {
SwiftyStoreKit.retrieveProductsInfo([inappIndentifier]) { result in
if let product = result.retrievedProducts.first {
let priceString = product.localizedPrice!
completion(true, priceString)
} else if let _ = result.invalidProductIDs.first {
completion(false, nil)
} else {
print("Error: \(result.error)")
completion(false, nil)
}
}
}
I made a huge mistake, instead of creating an iMessage extension, I've created an iMessage app extension.
Once I removed the "iMessage app" the in-app purchases started working correctly.

How to make the Facebook ads live?

I have added Facebook audience network in my iOS App for native ads integration. Everything is working fine but there are only testing ads.
I have added testDeviceKey for displaying ads if I try to remove this then no ads are displaying that is also making me confused. My code is -
#implementation AdFeedsView
FBNativeAd *nativeAd;
static NSString *adPlacementId = #"xxxxxxxxx";
- (void)showNativeAd:(UIViewController *)vc
{
nativeAd = [[FBNativeAd alloc] initWithPlacementID:adPlacementId];
nativeAd.delegate = self;
NSLog(#"isTestMode1: %d",[FBAdSettings isTestMode]);
NSString *testDeviceKey = [FBAdSettings testDeviceHash];
if (testDeviceKey) {
[FBAdSettings addTestDevice:testDeviceKey];
}
[nativeAd loadAd];
}
So I just want to ask that what changes should I need to do in my code so that we can see proper ads other than testing ads in my live app?
Finally I find the solution. Actually I have added the code
NSString *testDeviceKey = [FBAdSettings testDeviceHash];
if (testDeviceKey) {
[FBAdSettings addTestDevice:testDeviceKey];
}
that is making all the active devices as testing devices hence there are only testing ads. I have removed it in the live version and included the code
[FBAdSettings clearTestDevices];
We can also do
if ([FBAdSettings isTestMode]) {
[FBAdSettings clearTestDevice:[FBAdSettings testDeviceHash]];
}
I have a wrong perception about testmode. I think that it will be false when my app become live but actually it just tell that the device has been added as testdevice or not.
Swift 3
This code will make sure that your test ads show on testflight or the simulator/device and also will make sure when you release to the app store that your ads will be shown as LIVE ads and the test devices will be cleared.
If you have your ads in many places you can put this code in the AppDelegate
import FBAudienceNetwork
private func facebookAdsControl() {
#if RELEASE
self.clearTestDevicesForFacebookAds()
#else
self.addTestDevicesForFacebookAds()
#endif
}
///remove for live mode
private func addTestDevicesForFacebookAds(){
let key = FBAdSettings.testDeviceHash()
FBAdSettings.setLogLevel(FBAdLogLevel.Log)
FBAdSettings.addTestDevice(key)
}
///add for live mode
private func clearTestDevicesForFacebookAds() {
FBAdSettings.clearTestDevices()
}
call the: facebookAdsControl() in the didFinishLaunchingWithOptions
You can also call this code in the code where you have the ads but make sure you call it before adView.load()
In order to use the macro you have to add the flags to your Swift Flags in the Build Settings
I hope this helps someone as the Facebook Docs are not very clear as I have found out.

Resources