I'm trying to get the MKStoreKit working with my Cocos2D game. It look pretty simple to do and I've followed all the steps a couple of times (to check I've done it correctly) but I still can't get it to work. I can retrieve a product name, price and description etc. but I can use the shared MKStoreKitManager to make a purchase.
Here's my code for buying a product:
if([MKStoreManager isFeaturePurchased: #"com.testing.iap.removeAds"]) {
NSLog(#"No ads");
}else{
NSLog(#"Ads");
NSLog(#"Buying feature...");
[[MKStoreManager sharedManager] buyFeature: #"com.testing.iap.removeAds"
onComplete:^(NSString* purchasedFeature)
{
NSLog(#"Purchased: %#", purchasedFeature);
// provide your product to the user here.
// if it's a subscription, allow user to use now.
// remembering this purchase is taken care of by MKStoreKit.
}
onCancelled:^
{
NSLog(#"Something went wrong");
// User cancels the transaction, you can log this using any analytics software like Flurry.
}];
}
Basically if the product hasn't been previously purchased, kick off the purchase process. The problem is nothing happens! I don't even get the onCancelled being called and there are no error messages apart from the one's I can ignore (i.e. iCloud support and custom server options).
Can anyone shed some light on what it is thats stopping me?
Note: I'm testing on an iPhone 4 device running iOS 5.1
As soon as your app launches, call:
[MKStoreManager sharedManager];
That's it. As long as you call the -buyFeature: method after the products have been downloaded (you could observe kProductFetchedNotification if you want) everything works as expected.
I have no idea what wasn't working but after spending al most a full working day trying to get this to work I decided to start a new project from scratch and try again. I done everything exactly the same and it all worked!
Make sure you added your IAP key to the MKStoreKitConfigs.plist. Without that it does nothing.
Also it can take a few hours until a register IAP becomes available for testing.
Related
I have followed example from Chartboost i iOS. Even I have checkout all the Questions from Stackoverflow too. I have used their suggestions too, but not found Interstitials.
Even I have allow publish in network in Chartboost dashboard.
It works fine for the Firsttime when App is Installed on device and even if we delete the app and run xcode still the same issue that Chartboost not showing Interstitial. Every time it calls method as follows:
- (void)didFailToLoadInterstitial:(NSString *)location
I have also included below method:
- (void)didDismissInterstitial:(NSString *)location {
NSLog(#"chartboost*** dismissed interstitial at location %#", location);
[[Chartboost sharedChartboost] cacheInterstitial:location];
}
I haven't seen the Chartboost Ad in my App. I have also included the Method as follow to check whether Caching is available or not.
BOOL isCached = [[Chartboost sharedChartboost] hasCachedInterstitial:#"After level 1"];
and returns NO. In two screens I need Advertisement from chartboost. And I have given them two different Location Names too and calls them whenever needed.
How to overcome from this issue??
It's been 2 years so you already know the solution to your questions but for those who face this issue, you have to wait a few minutes sometimes even over 10 minutes for the 1st interstitial chartboost to show up whether live or test ad. When you delete your app and re-run it again on Xcode you have to wait again a long time. Sometimes longer than 10 minutes.
Is there a way (in code) that you can give an app different features based on when it was purchased??
I have people who have bought my app for a different price and some had it free during a promotion.
It would be nice to give a little thank you with an extra feature in my app for the ones who paid for it.
Is that in anyway possible?
Without having it in place beforehand, you won't ever know about the past, but nothing prevents you from putting the timestamp of when a user first opened your app into e.g. the user settings. Something like
[[NSUserDefaults standardUserDefaults]
setObject:[NSDate date]
forKey:#"install_date"];
which you could then use to decide how to "treat" (I guess) the user. The one catch is that if a user ever deletes the app and then reinstalls it, their early adopter bonus or whatever will be lost. The only other option you have is to send the device ID to a dedicated server somewhere, e.g. a PHP script with a simple MySQL db where device id's are stored along with dates. You could then do something like
NSDate *purchaseDate = [[NSUserDefaults standardUserDefaults]
objectForKey:#"purchase_date"];
if (nil == purchaseDate) {
// we need to get the date for this user from the server, or
// we need to register the user as it's the first time
} else {
// we know when this user installed the app, and they did so
// (approximately) at the purchaseDate time.
}
Date format issues aside, the above should be pretty straightforward, but as said, does require a server somewhere (which can be a slow mo because the above only happens on first install and reinstalls).
Edit: you can use [[UIDevice currentDevice] uniqueIdentifier] (deprecated as of iOS 5) or [[UIDevice currentDevice] identifierForVendor] (new as of iOS 6.. lol) to get the device ID.
You have to manage it by code officially Apple don't provide any code for that. But if in case you need any kind of analysis of app. Like , which part of app was used by user, which part makes crash of app, something kind of feature you can try this Flurry Analytics for it .
There is no way to detect from within your app when an app has been purchased. You could add detection of when it was installed, but that could have happened at any later time, even multiple times.
I am registering for Push Notification by calling the following piece of code:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
But in some rare cases following delegate does not get called:
- (void)application:(UIApplication *)iApplication didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)iNewDeviceToken {
Not even following method gets called:
- (void)application:(UIApplication *)iApplication didFailToRegisterForRemoteNotificationsWithError:(NSError *)iError {
What could be the reason for this. I am proceeding with my app flow once I received the device token. So, in some rare scenarios my app hungs.
Any clue?
According to the documentation, neither of the callbacks will happen until the device has a persistent connection with the push server. So if there is no wifi or data connection available, the callbacks won't happen - and apple doesn't regard this as an error condition. As far as I can tell, the only errors that can happen to cause the didFail... callback are an incorrect certificate/app permissions issue (a development problem), or the user declined permission (though I am only sporadically able to reproduce this by changing the date and turning the phone off).
The clue is right there: you get a NSError instance when it fails. So to figure out why it errors, inspect the NSError and see what its telling you.
You should probably at least handle that case in your app as well, such as showing an error message along the lines of "Failed to register application, please try again...".
One more thing: If you phone is rooted/jail broken for use with another network, etc., you will have problems. My phone was rooted and none of the delegates were called. I had a coworker put it on their iPad, and it worked fine, so I know the code was OK.
So, I reinstalled the OS on my phone, and it started working.
You have to enable the Push Notifications in the provisioning profile, set it up in the Developer Portal with the App Id. Then it should work.
Hi
I am trying to add game center to my iphone app.
I have done the following steps
1) I have added an app to my itnuesAccount
2) I assigned the Bundle ID as net.myCompany.myGameCenter
3) I am using the same "net.myCompany.myGameCenter" as Bundle identifier in my info.plist
4) using the sample code provided by apple i added the authentication steps.
self.currentLeaderBoard= kEasyLeaderboardID;
self.currentScore= 0;
[super viewDidLoad];
if([GameCenterManager isGameCenterAvailable])
{
self.gameCenterManager= [[[GameCenterManager alloc] init] autorelease];
[self.gameCenterManager setDelegate: self];
[self.gameCenterManager authenticateLocalUser];
[self updateCurrentScore];
}
else
{
[self showAlertWithTitle: #"Game Center Support Required!"
message: #"The current device does not support Game Center, which this sample requires."];
}
I have tried putting the kEasyLeaderboardID value equal to the one that i placed myself upon creating the new leader board.
I tried the other one, that i defined at step2. "myComap"
Other people who are stuck with this problem to this date, like me..
Turned out because my devices were jailbroken =/ .. I read an answer somewhere on stackoverflow.com that jailbroken devices interpret the app as a "real-world" app, thus not discovering sandbox accounts ..
I restored my iPad, and got an iPod touch from a friend, and both worked painlessly .. (previously, I tried it on 3 jailbroken devices, for which none of them worked ..).
Ah my bad
the BundleId at the iTunes connect and the one in the info.plist have to be same
and the leaderboardID is used for for submitting and viewing the score.
Many reasons are there for this problem
Add your app on itunesconnect.apple.com
Fill all information (Make Sure your available/publish date)
Can enter dummy data, but bundle id and name must be original as your real game.(Can't change)
then put your leaderboard/Achivement id in your app.
If still you getting same message "Game Center is not recognized this game", check your availability date which you have enter while filling the information of your app on itunesconnect.apple.com. This date should not be after your current date.
If again you are getting same problem then upload this app on AppStore. (After checking you can reject this uploaded binary)
Well, I tried every tips but still got this warning!!
Finally, I solved it by creating a new App on iTunes Connect!! After you've added a new App for your project, you need to press "Manage Game Center" and choose a group. Then your game will be recognized by the game center, even you haven't added 'Leaderboards' or 'Achievements'.
Gah! This was driving me crazy. I had done everything right, had all the correct bundleIDs, certificates, etc., my app is already in the app store, but I was still getting this message. (iOS9.x, XCode 7.1)
Turns out that adding a single achievement in iTunesConnect made things work. I suspect I could have added a leaderboard, instead.
Basically, the message can also mean "while your app says it's Game Center capable, it doesn't actually have any GC content" and adding an achievement or leaderboard makes the game "recognized" by GC.
Seems on iOS 8 GameCenter sandbox is disabled by default. I met a similar problem and solved by enabling Game Center sandbox in Settings and re-logining.
This is my first attempt at this and am falling at the get a list of products hurdle!
I have created a ad-hoc profile like: com.mycompany.myproduct and a additional feature on iTunes connect like com.mycompany.myproduct.feature.
The feature is linked to an existing app already on the store but not yet live with in app purchase that uses com.mycompany.myprod as its identifier.
I have build the new version using com.mycompany.myproduct and deployed to my phone and it works ok, apart from when I try to retrieve the list of products available (there is one setup on iTunes connect) I get a return count of 0
Am not sure where I am going wrong so would really appreciate some advice....
Thanks
This is an old question, but I thought I'd help clarify anyone else with this problem finding this through Google.
Check the invalidProductIdentifiers property of your SKProductsResponse object. It should be empty.
Part of what could be happening is that your identifiers aren't properly configured in iTunesConnect. They should be listed as "Ready to Submit" or "Waiting for Screenshot"
I have same problem, SKProductsRequest don't return products, and check everything according follow article's suggestion, and still don't return products.
Later I reset my iPod, set WiFi, and run again from XCode, it returned product list.
I am quite sure it was resetting iPod, fixed the problem.