How to know if admob are not coming in iOS? - iphone

I am using admobs and i want to know if admobs are not coming.
If admobs are not coming then i should hide that view and when they start coming again then i have to show them onscren.
if my question is silly then don't mind please.
any help?

You should use delegate functions to know whether ads are getting received or not and then handle it accordingly.
Use GADBannerViewDelegate
Implement delegate functions like this:
// We've received an ad successfully.
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(#"Received ad successfully");
}
// Ad Not Recieved
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"Failed to receive ad with error: %#", [error localizedFailureReason]);
}
- (void)adViewWillPresentScreen:(GADBannerView *)bannerView
{
NSLog(#"will Present");
}

Related

Can't connect to [QBChat Instance] connect with User, in Quickblox

I am using Quickblox Api, for chat and video chat. iOS. And I am using the latest version of the API
When I try to Make a video call,
most of the times i don't get video, only audio.
i get video on both ends 1 out of 15 times.
3 out of 10 times video on one end.
very weird. I have good internet connection. connecting to chat users are receiving the call. Can seem to find out the issue.
After spending sometime to find the issue, I received and help from Quickblox Help Center.
If your face such Behavior on the API
1.Make Sure that you set Delegate Methods in viewDidLod, not view did appear or etc. For Ex:
- (void)viewDidLoad {
[super viewDidLoad];
[[QBChat instance] addDelegate:self];
[QBRTCClient.instance addDelegate:self];
[QBSettings setCarbonsEnabled:YES];
}
Use Breakpoints to find out if they are getting called, once you make or receive calls.
2.Make Sure that your Calling methods are correct. An array containing Users must not equal to currentUser.ID.
NSInteger currentUserID = [QBSession currentSession].currentUser.ID;
int count = 0;
NSNumber *currentUserIndex = nil;
for (NSNumber *opponentID in opponentsIDs) {
if ([opponentID integerValue] == currentUserID) {
currentUserIndex = #(count);
break;
}
count++;
}
if (currentUserIndex) [opponentsIDs removeObjectAtIndex:[currentUserIndex intValue]];
QBRTCSession *session = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs
withConferenceType:QBRTCConferenceTypeVideo];
NSDictionary *userInfo = #{ #"key" : #"value" };
[session startCall:userInfo];
if (session) {
self.currentSession = session;
[self performSegueWithIdentifier:#"openDialogSeg" sender:self];
}
else {
[SVProgressHUD showErrorWithStatus:#"You should login to use chat API. Session hasn’t been created. Please try to relogin the chat."];
}
}
Check View Layout, size and width. make sure they are set correctly.

In-app purchase, how to provide consumables after purchase

I am trying to implement IAPs in one app and I'm almost there but still facing some problems. I already posted another question before of this because I found an incomplete tutorial that was missing something so I was stuck and someone already helped me out with that... but in that tutorial they were using a table while I just want to use normal buttons. Between various answers there was an answer that gave me a new way to approach this matter.. so I am giving it a try but here comes the problems I found:
I am getting a warning, the guy told me in the answer to include each of the following protocols in my header file:
SKProductsRequestDelegate
SKPaymentTransactionObserver
SKRequestDelegate
and I did it with this code:
#interface BuyTest2 : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver, SKRequestDelegate>
but now I'm getting this warning in m file:
Method 'paymentQueue:updatedTransactions:' in protocol not implemented
why is that? Am I missing something? (I'm sure I am...)
when I click button to buy Coins everything works fine but after the purchase has been done I don't know how to deliver the coins... I have my code to do it but I don't know where to put it... how should I do that?
if I try again to make a test purchase I get the message that I already bought that item and that I have to click on 'OK' to download it... but after that nothing happens... and I really don't have to give something to download but I just need to add some coins to a variable and then save it with NSUserDefaults...
here is the code I am using:
in file .h i got
#interface BuyTest2 : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver, SKRequestDelegate>
#property (nonatomic, retain) SKProduct *currentProduct;
#property(nonatomic, readonly) SKPaymentTransactionState transactionState;
#property (nonatomic, retain) SKProductsRequest *ualRequest;
and in file .m i got:
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
if(response.products.count > 0)
{
SKProduct* product;
for(int i = 0; i<response.products.count; i++)
{
product = [response.products objectAtIndex:i];
if([product.productIdentifier isEqualToString:#"com.mycompany.myapp.1"])
{
self.currentProduct = product;
[self beginPaymentWithProduct:product];
}
}
}
}
- (void)beginPaymentWithProduct:(SKProduct*)product
{
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (BOOL)canMakePurchases
{
return [SKPaymentQueue canMakePayments];
}
- (IBAction)buyCoins:(id)sender
{
if([self canMakePurchases])
{
ualRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[NSArray arrayWithObjects: #"com.mycompany.myapp.1", nil]]];
[ualRequest setDelegate:self];
[ualRequest start];
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction* transaction in transactions) {
if (transaction.transactionState == SKPaymentTransactionStatePurchased) {
NSLog(#"Transaction Purchased: %#", transaction);
// Make purchase available to the user, etc...
// Once that's all done...
[queue finishTransaction:transaction];
}
else if (transaction.transactionState == SKPaymentTransactionStateFailed) {
NSLog(#"Transaction Failed: %#", transaction);
// Display error to the user, using the error text in the transaction
// This example uses NSLog, typically you'd use UIAlertView here
NSLog(#"Error: %#", [transaction.error localizedDescription]);
}
}
}
Thanks for any help...
but now I'm getting this warning in m file:
Method 'paymentQueue:updatedTransactions:' in protocol not implemented
The error message is very informative here. paymentQueue:updatedTransactions: is part of the SKPaymentTransactionObserver protocol, and is a required method (meaning, you have to implement it if you are to become an observer of payment transactions. Remember, warnings are something you should take a serious look at, and typically you should consider them as errors). The documentation for this protocol can be found here.
The discussion for this particular method is fairly clear on it's purpose, and what you are required to do. It is the means to check whether a transaction has gone though, and if it has it is your responsibility to provide the functionality/content to the user.
The application should process each transaction by examining the transaction’s transactionState property. If transactionState is SKPaymentTransactionStatePurchased, payment was successfully received for the desired functionality. The application should make the functionality available to the user. If transactionState is SKPaymentTransactionStateFailed, the application can read the transaction’s error property to return a meaningful error to the user.
Once a transaction is processed, it should be removed from the payment queue by calling the payment queue’s finishTransaction: method, passing the transaction as a parameter.
The best documentation on how to use the IAP system is available from Apple, and I strongly recommend you give it a good read. It is available here.
Update:
Here is a code snippet showing the general gist of what's required in this method:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction* transaction in transactions) {
if (transaction.transationState == SKPaymentTransactionStatePurchased) {
NSLog(#"Transaction Purchased: %#", transaction);
// Make purchase available to the user, etc...
// Once that's all done...
[queue finishTransaction:transaction];
}
else if (transaction.transactionState == SKPaymentTransactionStateFailed) {
NSLog(#"Transaction Failed: %#", transaction);
// Display error to the user, using the error text in the transaction
// This example uses NSLog, typically you'd use UIAlertView here
NSLog(#"Error: %#", [transaction.error localizedDescription]);
}
}
}
And remember to register yourself for events. You can do this via:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
Add these in the appropriate places, such as init/dealloc. Do refrain from using this in viewDidLoad, as this is more of a visual thing, and not a data model concern.

Parse push notification in iphone

Integrated parse push notification in iOS project. Not working.
Here is my code:
#ifdef ENABLE_PARSE_PUSH
#import "Parse/Parse.h"
#endif
//in appDelegate didFinishLaunchingWithOptions
#ifdef ENABLE_PARSE_PUSH
// Obtain the installation object for the current device
[Parse setApplicationId:PARSE_APP_ID clientKey:PARSE_APP_SIGNATURE];
PFInstallation *myInstallation = [PFInstallation currentInstallation];
// Save some data
[myInstallation setObject:#"YES" forKey:#"scoreUpdates"];
// Save or Create installation object
[myInstallation saveInBackground];
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
#endif
#ifdef ENABLE_PARSE_PUSH
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken
{
[PFPush storeDeviceToken:newDeviceToken]; // Send parse the device token
// Subscribe this user to the broadcast channel, ""
[PFPush subscribeToChannelInBackground:#"" block:^(BOOL succeeded, NSError *error) {
if (succeeded)
{
//#ifdef DEBUG
//NSLog(#"Successfully subscribed to the broadcast channel.");
//#endif
}
else
{
//#ifdef DEBUG
//NSLog(#"Failed to subscribe to the broadcast channel.");
//#endif
}
}];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
#endif
here is one similar post not helped for me..tried all suggested solutions. What's wrong..already uploaded development push SSL in parse.com. help me to get solution.
Now test push message from parse.com is not delivering in device.
Hi Have you try this Parse step by step Tutorial
https://www.parse.com/tutorials/ios-push-notifications
Follow the tutorial and if you get stack you can post here for help .
Ok Finally resolved this problem.
• We need to create new provisioning profile after configuring push SLL in app id section. Then we need to use new provisioning profile.
This solved my problem and now getting test push message from Parse.

iOS Native Facebook Share no internet callback

I'm trying to implement the native facebook share for iOS 6 and need check if a share did succeed or not. This is the code I have used:
BOOL displayedNativeDialog =
[FBNativeDialogs
presentShareDialogModallyFrom:delegate
initialText:#"test"
image:nil
url:nil
handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
/* handle failure */
NSLog(#"error:%#, %#", error, [error localizedDescription]);
} else {
if (result == FBNativeDialogResultSucceeded) {
/* handle success */
NSLog(#"handle success");
} else {
/* handle user cancel */
NSLog(#"user cancel");
}
}
}];
if (!displayedNativeDialog) {
/* handle fallback to native dialog */
}
My problem is when I try this with no internet connection available I still get the FBNativeDialogResultSucceeded
It looks like you should get an error when no internet connection is available but it seems that it doesn't work like that.
If there are some solution where I don't need to use the reachability SDK that would be great.
You'll likely have to use the reachability SDK at this point. The Facebook SDK builds on top of the SLComposeViewController for the native functionality. That view controller returns two possible choices:
SLComposeViewControllerResultCancelled
SLComposeViewControllerResultDone
SLComposeViewControllerResultDone: The view controller is dismissed and the message is being sent in the background. This occurs when the user selects Done.
So since Facebook mirrors this the success case means the user clicked done and the message has been sent in the background.
However if you run this and there is no internet connection, the user should still see a pop-up indicating that the post could not be sent due to a connection failure.

Facebook iPhone SDK: show a progress bar while uploading an image

I want to show a progress bar while my iPhone app is uploading an image to Facebook. Is it possible?
Can I do it with every FBRequest that I make? I also use FBRequest to check extended permission and sometimes takes a lot of time.
Thank you.
For the progress bar there is a little hack you can do. In the FBRequest.h file add this line in the FBRequestDelegate protocol:
- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
After that in the FBRequest.m file add this function:
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
if ([_delegate respondsToSelector:#selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
[_delegate request:self didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
}
}
Now your delegate will receive a message every time more data it's posted to the server. So basically if you implement this into your delegate you should see some activity in your log:
- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
NSLog(#"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
}
Let me know if you have any problems hacking this into the current Facebook SDK.
You can't know when it gonna log you in but you can put an UIActivityIndicatorView.
You start it when you click on publish button and you end it when you enter the 'didConnect' method