How to set up SandBox In-App Purchase in IOS - ios

I integrated the In-App purchase for my app. I also set the purchase on itunes & shows me status as Ready to Submit.
But I want to test it without submitting the binary.
So, Is there is another set required for Sandbox In-App testing?
My code:
[[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success)
{
[appDel dismissGlobalHUD];
NSMutableArray *arrProductsBuyHeart = [[NSMutableArray alloc]init];
NSMutableArray *arrTemp = [[NSMutableArray alloc]init];
for (SKProduct *Sss in products)
{
NSString *string = Sss.productIdentifier;//#"hello bla bla";
if ([string rangeOfString:#"com.xxxxxxxx.buy"].location == NSNotFound) {
//NSLog(#"string does not contain Buy");
} else {
NSMutableDictionary *dictprod = [NSMutableDictionary dictionary];
[dictprod setObject:Sss.productIdentifier forKey:#"ProductIdentifier"];
[dictprod setObject:Sss.price forKey:#"ProductPrice"];
[dictprod setObject:Sss.localizedTitle forKey:#"ProductTitle"];
[arrTemp addObject:dictprod];
}
}
if (arrTemp.count > 0)
{
NSSortDescriptor *brandDescriptor = [[NSSortDescriptor alloc] initWithKey:#"ProductPrice" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:brandDescriptor];
arrProductsBuyHeart = [NSMutableArray arrayWithArray:[arrTemp sortedArrayUsingDescriptors:sortDescriptors]];
//NSLog(#"My products > %#",arrProductsBuyHeart);
for (int i = 0;i<[arrProductsBuyHeart count];i++)
{
NSString *strProductID = [[NSString stringWithFormat:#"%#",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:#"ProductIdentifier"]]RemoveNull];
NSString *strPrice = [[NSString stringWithFormat:#"$%#",[[arrProductsBuyHeart objectAtIndex:i] objectForKey:#"ProductPrice"]]RemoveNull];
if ([strProductID isEqualToString:InApp200Coins])
{
[btn1KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp600Coins])
{
[btn2KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp900Coins])
{
[btn4KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp2KCoins])
{
[btn10KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
else if ([strProductID isEqualToString:InApp4KCoins])
{
[btn50KHeart setTitle:[NSString stringWithFormat:#"%#",strPrice] forState:UIControlStateNormal];
}
}
}
else
DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found.");
}
else
{
[appDel dismissGlobalHUD];
DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found.");
}
}];
}
Output DisplayAlertWithTitle(#"Error Message", #"Unable to get product list or no in-app purchase found."); & Not able to get Product List.
Help me to solve this.

First of you can create app in itunes connect.
-add product in In-app purchase.
-then after itunes home page you can add test user click on manage user.
after add you can remove your apple account in your device then login with test user
after login you can test in-App purchase in Sandbox mode.

Create a test user account in iTunes Connect, as described in “Creating Test User Accounts” in iTunes Connect Developer Guide.
On a development iOS device, sign out of the App Store in Settings. Then build and run your app from Xcode.
On a development OS X device, sign out of the Mac App Store. Then build your app in Xcode and launch it from the Finder.
Use your app to make an in-app purchase. When prompted to sign in to the App Store, use your test account. Note that the text “[Environment: Sandbox]” appears as part of the prompt, indicating that you’re connected to the test environment.
If the text “[Environment: Sandbox]” doesn’t appear, you’re using the production environment. Make sure you’re running a development-signed build of your app. Production-signed builds use the production environment.
Important: Don’t use your test user account to sign in to the production environment. If you do, the test user account becomes invalid and can no longer be used.

Related

Empty Auto-Renewing iOS In-App purchases from SKProductsRequest initWithProductIdentifiers

I've made an iOS in-app Auto-Renewable Subscription, now I'm trying to allow users to purchase it in a React-Native app.
I've found react-native-in-app-utils, but can't seem to even load my products. I have 3 "products" (auto-renewable subscriptions) in iTunes connect, but trying to load them with:
var products = [
'com.xxxx.app.monthly',
'com.xxxx.app.6months',
'com.xxxx.app.year',
];
InAppUtils.loadProducts(products, (error, products) => {
console.log('products:', products);
});
just logs "products: []".
Digging a little deeper, I've added some additional logging to the objective-c code doing the querying, and it looks like:
NSLog(#"loading products %#", productIdentifiers);
if([SKPaymentQueue canMakePayments]){
SKProductsRequest *productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithArray:productIdentifiers]];
productsRequest.delegate = self;
_callbacks[RCTKeyForInstance(productsRequest)] = callback;
[productsRequest start];
} else {
callback(#[#"not_available"]);
}
Then in the callback:
NSLog(#"products response %#", response.products);
products = [NSMutableArray arrayWithArray:response.products];
NSMutableArray *productsArrayForJS = [NSMutableArray array];
for(SKProduct *item in response.products) {
NSDictionary *product = #{
...
This will log "loading products" with my product ids, as expected. But then "products response ()"... empty response.
Those products are listed in iTunes connect as "Ready to Submit". And they've been added to the app info under In-App Purchases. What gives? Why aren't the products showing up?
Looks like it was an administrative issue, not a technical one. Project Manager hadn't put through the paid app agreement.

How to test In-app purchase in Sandbox mode iOS?

Am new to In-app purchase integration in iOS application. I have done the coding in the project level and I have created a Sandbox user in iTunes Connect. I read many tutorials and Apple Document to test the In-App purchase in DEV mode.
As per the document I have removed the APPLE ID from iPad Settings and launched the app from Xcode. But, I didn't received the Account Alert from the app. Also, my products are returning empty in SKProductRequest delegate method didReceiveResponse. I have posted my code for your reference. Can you please help me on this? Am working since last two days. Please help me. Thanks in advance.
- (void) getAvailProducts
{
NSLog(#"Fetching Available Products");
NSSet *productIdentifiers = [NSSet setWithObjects:#"com.test.testios.monthly", #"com.test.testios.yearly" ,nil];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
//SKProduct *validProduct = nil;
DebugLog(#"\n Products: %#", response.products);
NSUInteger count = [response.products count];
NSLog(#"Request Count: %lu", (unsigned long)count);
if (count > 0)
{
self.validatedProducts = response.products;
DebugLog(#“\n Products: %#", response.products);
self.validationCheck = TRUE;
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
// Check subscription
}
else
{
// No products found….
}
}
Also, I tried with "monthly and yearly" instead of "com.test.testios.monthly and com.test.testios.yearly". But, no results.
Edit: Am getting the mentioned ProductIds are invalid in the following code,
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(#"Invalid product id: %#" , invalidProductId);
}
Thank you all.
Fixed the issue and tested the In-App purchase in Sandbox environment. Following items fixed my issue,
1. iTunes Agreement was not accepted.
2. Tax and Payment details was not added.
3. Added correct Product Identifier in project.

why publishing to facebook wall using graph api results authenication error in iOS?

My iOS app is live and I have used Facebook Graph API for publishing the post but suddenly i am getting complain that post sharing gets fail.I have checked with facebook developer forum and they are talking about i need to add one more permission for that which i added but still i am getting same error.Here I am posting my code what i have did it for publishing on facebook wall.Please share some ideas on that.
if ( (self.fbGraph.accessToken == nil) || ([self.fbGraph.accessToken length] == 0) ) {
[self.fbGraph authenticateUserWithCallbackObject:self andSelector:#selector(fbGraphCallback:)andExtendedPermissions:#"email,publish_stream,public_profile,user_checkins,publish_actions,status_update,user_friends,read_stream,user_photos,friends_photos"];
}
else
{
if([self.fbGraph.accessToken length] > 0){
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4];
NSString *Header;
if(self.AutoMatedSahre==100){
Header=[NSString stringWithFormat:#"'%# is planning to use this offer'\n%#",[[self.shareDelegate.userdetails valueForKey:#"firstname"] capitalizedString],[self.dForDetail valueForKey:#"business_name"]];
}else{
Header=[self.dForDetail valueForKey:#"business_name"];
}
NSString *dealdesc=[NSString stringWithFormat:#"%# offer on ABC.\n %#.\n http://www.example.com/deal_summary.html?deal_id=%#",[self.dForDetail valueForKey:#"business_name"],[self.dForDetail valueForKey:#"deal_name"],[self.dForDetail valueForKey:#"id"]];
[variables setObject:dealdesc forKey:#"message"];
[variables setObject:Header forKey:#"name"];
[variables setObject:[self.dForDetail valueForKey:#"image_url"] forKey:#"link"];
FbGraphResponse *fb_graph_response = [self.fbGraph doGraphPost:#"me/feed" withPostVars:variables];
NSLog(#"postMeFeedButtonPressed: %#", fb_graph_response.htmlResponse);
//parse our json
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
[parser release];
self.feedPostId = (NSString *)[facebook_response objectForKey:#"id"];
I am getting following Response:
postMeFeedButtonPressed: {"error":{"message":"(#200) The user hasn't
authorized the application to perform this
action","type":"OAuthException","code":200}}
You need to get approval from facebook by resubmitting or submitting your app with review again the permission is publish_action check facebook dev documentation about this particular permission and you will get the process needed for submitting for a review.
Here is the link

"Error occurred" facebook login in ios application

i have integrate the facebook sdk for post something on facebook.Its working for only single facebook-id which is used for integrating facebook it in my application, not working for other.
this is my code
-(IBAction)postOnFacebook:(id)sender {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Sharing Tutorial", #"name",#"Build great social apps and get more installs.", #"caption", #"Allow your users to share stories on Facebook from your app using the iOS SDK.", #"description",#"https://developers.facebook.com/docs/ios/share/", #"link",#"http://i.imgur.com/g3Qc1HN.png", #"picture",nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
// A function for parsing URL parameters returned by the Feed Dialog.
- (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:#"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:#"="];
NSString *val =
[kv[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
params[kv[0]] = val;
}
return params;
}
this meth
Error come when i use another id for login
You are using the publish_action permission which can be made availaible to all users only after approval from facebook.
Currently you might have created the facebook app in your account and with that account id you will be able to post to facebook. This is because of the reason that facebook gives all the permissions to users who are added as Developers/Testers in the App Dashboard.
You can add people to your app as Testers/Developers by following the steps as described below
You'll need to be an admin to give someone a role on your Page. If the person is your Facebook friend:
Go to your Page and tap More.
Tap Edit Settings > Page Roles.
Tap Add Person to Page. You may need to enter your password to continue.
Begin typing a friend's name and tap their name from the list that appears.
Tap to choose a role > Add.
If the person isn't your Facebook friend, you can log into Facebook from a computer and add them by entering their email address.
Depending on their settings, the person may receive a notification or an email when you give them a role.
These users who are added will have all the permission that you are requesting.
If you want the permissions to be availaible to everyone, your facebook app should be approved and for that you have to submit your app to facebook for review. The guidelines for facebook app submision can be found from the following link
https://developers.facebook.com/docs/apps/review
Hope this helps you
I'm not sure if I understood your question.
But, for what I'm seeing. If you have created app at facebook (to integrate with your iOS app) you have to use the facebook app ID only, presented at Facebook.
Or, if this error is because you are trying to login with another facebook account. This is happening probably because you did not publish your app yet (facebook app). So it's not available to everyone, but its ok because you probably don't want to make it available right now. So you just need to go to the left menu at Roles in your facebook app page and add test users (the account that you're trying to login) or add as administrator.

In app purchase Developer action needed Status

I am working on IAP first time i have not uploaded any version on app store we have included IAP in first version. i have submitted IAP Three times but still everytime we get Developer action needed status. I have created test user and working good in sandbox env. Now if i have uploaded app on store will IAP works??
Belo code got information in sandbox env now what to do for actual working means when i uplaod app on store will it work same as sandbox mode,
-(void)productsRequest:(SKProductsRequest *)request
didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct = nil;
int count = [response.products count];
if (count>0) {
validProducts = response.products;
validProduct = (response.products)[0];
if ([validProduct.productIdentifier
isEqualToString:kTutorialPointProductID]) {
NSLog(#"All product title is --%#",validProduct.localizedTitle);
NSLog(#"All product prize is %#", validProduct.price);
NSLog(#"All des is %#",validProduct.localizedDescription);
NSLog(#"response products is %#", validProduct.productIdentifier);
NSLog(#"AL*****%#", validProduct);
}
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:#"Not Available"
message:#"No products to purchase"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[tmp show];
}
}
Goto iTunes connect- >Manage APPs -> Manage In app Purchase -> Select your in app purchase
Make sure the product Cleared for Sale Yes and add screenshot for review.
Make sure IN- APP Purchase Details have Proper Display Name and Description
In iTunes connect- > Manage APPs -> View Details of the app.
Below Demo Account Information (Optional)
There is IN APP PURCHASE.You need to select the appropriate in app and save before You proceed with Ready to Submit.
if your in app purchase works fine with SandBox account then it is working fine !!!

Resources