This is my code:
let request = GADRequest()
request.testDevices = [kGADSimulatorID, "XXXX2F32d69CCA859FFB559D0FEA3CF6483D08A6"]
adView.load(request)
Where XXXX is my UDID of my iPhone. Why do I get real ads and not test ads on my iPhone? Test ads on the simulator works. Thank you. Tried the UDID in uppercase and lowercase.
This fixed it for me!
Product -> Scheme -> Arguments -> Environment Variables if there is a key: OS_ACTIVITY_MODE, disable/remove it.
As mentioned in admob guide
while running the app in device you get the below log
<Google> To get test ads on this device, call: request.testDevices = #[
#"2077ef9a63d2b398840261c8221a0c9b" ];
use that id instead of UDID.
As I understood your, I concate your UDID and ID in the log. This is wrong.
You this - pure ID :
let request = GADRequest()
request.testDevices = [kGADSimulatorID, "2F32d69CCA859FFB559D0FEA3CF6483D08A6"]
adView.load(request)
https://firebase.google.com/docs/admob/ios/targeting
Related
I've been trying to use the verifyReceipt endpoint to verify in-app purchase transactions with no success.
Here's how I'm doing it.
1. Read the receipt data in iOS (this is copy paste from Apple's documentation):
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
do {
let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
print(receiptData)
let receiptString = receiptData.base64EncodedString(options: [])
// sendReceiptToBackEnd(receiptString)
}
catch { print("Couldn't read receipt data with error: " + error.localizedDescription) }
}
2. In the backend, I followed this advice from Apple:
As a best practice, always call the production URL for verifyReceipt first, and proceed to verify with the sandbox URL if you receive a 21007 status code.
So first I try this (python code):
data = {
'receipt-data': receipt_string, # this is what we get from the frontend
'password': settings.APP_STORE_SHARED_SECRET
}
url = 'https://buy.itunes.apple.com/verifyReceipt'
response = requests.post(url, json=data)
response_data = response.json()
status = response_data['status']
Status here is 21007, which is expected according to the advice above. So then I try the sandbox:
url = 'https://sandbox.itunes.apple.com/verifyReceipt'
response = requests.post(url, json=data)
response_data = response.json()
status = response_data['status']
And I get 21002 - which means there's probably something wrong with what I sent.
Initially I was trying to test this using Xcode locally, but I found out later that verifyReceipt doesn't work with this feature because app's are not signed by the App Store. So I deleted the local configs and set the StoreKit Configuration in scheme back to none, and verified the app is using the App Store Connect as it was picking up any changes I made there in the price.
I'm out of ideas on how to debug this further, so I'm wondering could it be because the App & IAPs are not submitted yet? Currently the app is in the "Prepare for Submission" state, and the IAPs are in the "Ready to Submit" state. Or maybe there is something else I'm missing?
Edit: The answer to my question is "yes, you can." I copied and pasted the json and sent it manually using Postman and it worked fine so something is happening in the backend. I'm leaving the question for reference but if someone recommends deleting please let me know.
I saw your edit, but just as a follow-up code 21002 is a "malformed body" response (or theoretically an Apple server issue, but I've only seen it when mangling the receipt data).
You can see the full list of codes and meanings here:
https://developer.apple.com/documentation/appstorereceipts/status
Incidentally, as you build our your server to process iTunes responses you may find this guide useful for processing the receipt on the server:
https://www.namiml.com/blog/app-store-verify-receipt-definitive-guide
In app purchases work fine for my iOS side of things. The data from StoreKit is populated as it should. The same code doesn't work on the Mac Catalyst version of the project. I have even created a listing for my Mac app on App Store connect with different bundle identifiers for the in app purchases. I have a print function that returns what product StoreKit found, it works well on iOS, but results with nothing when using Mac Catalyst.
Here is what I have done:
Make sure that In App purchases has been added in the capabilities section.
Make sure the Store Kit framework has been imported.
Make sure the bundle identifiers are correct.
Make sure all agreements are filled out.
I am signed out of the Mac App Store.
Code that works on iOS but not on MacOS:
override func viewDidLoad() {
SKPaymentQueue.default().add(self)
let productIds: Set<String> = ["..."]
var request = SKProductsRequest(productIdentifiers: productIds)
request.delegate = self
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("Loaded")
for product in response.products {
print("What came: \(product.productIdentifier) \(product.localizedTitle) \(product.price.floatValue)")}
The iOS app will return with the Product Identifier, Title and Price. The Mac app will return with nothing at all.
I found the problem. I had not created a strong reference to my product request.
This line of code fixed my issue:
var request: SKProductsRequest!
I implemented AdMob into my app and linked it with Firebase which I am also using for database.
Before that I tried AdMob on new, sample project to see how it works. Its pretty simple so I put it in my app project.
AppDelegate
GADMobileAds.configure(withApplicationID: "myAppID")
Problem is that I made everything as necessary but my ad is not showing up as it did in sample project. I ran app on my device and added bannerView and configuration for it
let request = GADRequest()
request.testDevices = [kGADSimulatorID, "myDeviceID"]
bannerView.adUnitID = "myID"
bannerView.rootViewController = self
bannerView.load(request)
Problem here it because if I enter Firebase testing purpose adUnitID to test it, it works but with mine it doesn't.
Any ideas?
I am trying to launch Health app from my application.
I usually try with the following lines of code for launching application like as
let mystr = "health://"
let myurl = NSURL(string: mystr)!
if (UIApplication.sharedApplication().canOpenURL(myurl))
{
UIApplication.sharedApplication().openURL(myurl)
}
else
{
print("unable to open")
}
I tried above code.i am getting error ("null").
Some one please help in this issue.
Thanks in advance.
With iOS 10+ try this:
let mystr = "x-apple-health://"
Maybe in objective.c:
-(IBAction)openAppHealth:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"x-apple-health://"] options:#{} completionHandler:nil];
}
with new openURL for iOS 10
openURL: deprecated in iOS 10
You cannot open HealthApp directly from your app. Because OS is supporting only for opening the settings App using UIApplicationOpenSettingsURLString. If we use URL scheme to open the HealthApp, then Apple may reject the App in review process.
I don't have any experience with the HealthKit framework but here's what I found :
According to Open Apple Health programmatically you cannot create a deeplink from your app to the Health app because it is not supported.
If you'd wish to use the Health app's data you'll have to implement the HealthKit framework into your app and asks for permission to your users.
I tried to deeplink into the Health app using code that works for other apps and got the same results as you.
adwhirl(iad, admob, houseAd) add to xcode4
deviece test...
iad : ok see service
houseAd : ok see service
but...
admob : not see!!!
log code
2011-10-19 13:38:07.739 KingKatWorldFree[948:707] <Google> Invalid Request: {
errors = "Cannot determine request type. Is your ad unit id correct?";
"google.afma.notify_dt" = 1318999087687;
"request_id" = undefined;
type = unknown;
}
Why admob not See????
plese help me!!!!
When you configured AdMob on the AdWhirl backend with your AdMob publisher ID, check to make sure there is no whitespace before or after your ID. Otherwise AdMob will not recognize your publisher ID.