SpriteKit Game - SKScene Freezes during In-App Purchase in iOS 8.3 - objective-c

I have developed my first SpriteKit game and implemented in-app purchase in SKScence (not UIViewController). In my SKScene, there are locked items and all have zPosition<=+10. When user touches on any locked item, a transparent background (SKSpriteNode named "bgTransparent") appears on the top of all those items with zPosition=+20 and then another SKSpriteNode named "connectingMSG" (an image with message "connecting to Apple Store") appears on the top of transparent background with zPosition=+30. Once purchase is made, then I am removing locks, bgTransparent and connectingMSG using "removeFromParent"
bgTransparent =[SKSpriteNode
spriteNodeWithImageNamed:#"Bg_New_Moon_1_2320.png"];
[bgTransparent setScale:.25];
bgTransparent.size = self.frame.size;
bgTransparent.position= CGPointMake(0,0);
bgTransparent.zPosition= +20;
bgTransparent.alpha=0.55;
bgTransparent.anchorPoint = CGPointZero;
bgTransparent.name=#"bgTransparent";
[self addChild:bgTransparent];
connectingMSG =[SKSpriteNode
spriteNodeWithImageNamed:#"connectingTo_1.png"];
[connectingMSG setScale:.36];
connectingMSG.position= CGPointMake(self.size.width/2-60, 80);
connectingMSG.zPosition= +30; // top of bgTransparent
connectingMSG.anchorPoint = CGPointZero;
connectingMSG.name=#"connectingMSG";
[self addChild:connectingMSG];
[connectingMSG removeFromParent];
[bgTransparent removeFromParent];
In-app purchase is working fine in iOS 8.2. I tested it on iPad with iOS 8.2 and all simulators (iOS8.2). I also developed this game in Xcode 6.2 with base SDK iOS 8.2. Submitted it to APPLE and game got REJECTED because they tested it on iOS 8.3 and they found a bug (no crash). In iOS 8.3, user can buy and complete In App Purchase, Purchase confirmation appears, Tap on OK and modal alert disappears but no further action occurs and In App Purchase remains locked.
I upgraded my iPad to iOS 8.3 and what happening is that scene is freezing as soon as in app purchase screen appears. For Example: connectingMSG,bgtransparent are not being removed even if I click cancel on following screen and don't sign-in while they disappear in iOS 8.2
http://i.stack.imgur.com/f3O3K.png
same happens when I sign-in and make purchase. It freezes and nothing happens after touching again and again.
In console, it shows all NSLog messages that I am using after removing connectingMSG, bgTransparent and locks. So I know that code is running till end and removefromParent code i. It just doesn't remove SpriteNodes and refresh screen.
It is still working fine on iOS 8.2 but not on iOS 8.3. How do I fix it? Is it freezing because I am purchasing directly from SKScence (not UIViewController).
Please reply.

Related

iOS 8.3 in app purchase

So after updating to iOS 8.3 and xCode 6.3, I'm getting a bug when trying to do an in app purchase. When that Sign In screen pops up, it seems that my game freezes but it doesn't crash. When I click on cancel and that message goes away, none of my buttons work. The frame rate and node count at the bottom of the screen is also frozen and it just sits there until I quit the game.
My in app purchase works fine with iOS 8.2 and lower, but after updating to 8.3 this problem happens. Does anyone know what is going on here?

iOS8 Today Widget inside an iOS7 App?

Given that the current uptake of iOS8 is only 50% I don't want to make my next release exclusive to iOS8.
It would appear from playing with Xcode that one can compile a target, such as the today extension, for iOS8 without changing the main App and leaving it at iOS7.
Has anyone successfully updated an App which is iOS7+ including an iOS8 Today Widget extension?
I managed to get my iOS7.0+ App, with an iOS8.0 "Today Extension", past Apple iTunes review and into the store. It works well too.
So to answer my own question, yes you can put an iOS8 Today Widget inside an iOS7 App.
Just make sure you have the correct "Deployment Target" iOS version set under "Targets" for the App and the extension.

how to keep ios app using opentok video chat in foreground

I've integrated opentok ios sdk in my iOS 7 app, it is working fine, except this problem:
During video chat if I don't access iPhone for 5-10 seconds..then my app moves into background, causing viewer at other end to hear only audio. Video is disabled after app goes to background state.
I've observed same thing with their official example
https://github.com/opentok/opentok-ios-sdk/tree/master/samples/OpenTokFullTutorial
How can I avoid my app going to background while video chat is ongoing. Skype is working fine in this case, I want to achieve same thing.
What you want to do is prevent the iPhone from going to sleep. To do this, you cant try this:
[UIApplication sharedApplication].idleTimerDisabled = YES;
Here is iOS documentation on idleTimerDisabled
If you don't want the app going into background at all (like when the user taps on home button), you can opt to kill the app when it's not running instead of having it run in the background. To do that, check out iOS guide on opting out of background execution
If you do not want your app to run in the background at all, you can
explicitly opt out of background by adding the
UIApplicationExitsOnSuspend key (with the value YES) to your app’s
Info.plist file. When an app opts out, it cycles between the
not-running, inactive, and active states and never enters the
background or suspended states. When the user presses the Home button
to quit the app, the applicationWillTerminate: method of the app
delegate is called and the app has approximately 5 seconds to clean up
and exit before it is terminated and moved back to the not-running
state.
Hope that helped!

MPVolumeView no longer works on iOS 7 devices

So far I've been using an MPVolumeView to control the volume of my iOS devices, which worked just fine until updating to iOS7.
I've created a test project (Base SDK 6.1, Deployment Target 5.1) which has only one MPVolumeView on a single UIView. While running this App on my iPad 1 (iOS 5.1) works just fine, running it on my iPhone 5 (iOS 7) does not.
On my iPad dragging the volume slider changes the whole devices volume. Also when i use the hardware buttons this does reflect on my slider in the VolumeView. On my iPhone on the other hand, it seems that there is no longer a connection between those controls. The hardware buttons do not result in any changes on my VolumeView, neither does changing the slider in the volume control result in the devices volume level.
I need to have e.g. the iPodMusicPlayer playing something, then it works. Otherwise it doesn't.
Does anyone how i can get this to work again? I really need to control the whole devices audio level (not necessarily programmatically, the user needs to be able to change it within my app), not only the level of the sound played by the app itself.
After Long research i had delivery the answer to here. But i am not sure try with this if you get any issues let me know
Instead of MPVolumeView, you can also use:
AVAudioPlayer *testPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:#"m" ofType:#"caf"]] error:nil];
[testPlayer prepareToPlay];
prior to installing the MPVolumeView.
if your app that uses Audio session mode AVAudioSessionModeVoiceChat does not allow the MPVolumeView to work as well with no workaround.

How can you disable the iOS Notification Center within your App?

If you have a full screen iOS app and you want to prevent the notification center from being pulled down, can you and how?
Also can you block notification alerts or banners from displaying while your app is loading? (I think this is a no way for sure but wanted to ask just in case.)
It has been my experience that fullscreen apps (statusBarHidden = YES) have a slightly different notification center behavior by default: Swiping down over the area previously occupied by the status bar will only show a little tab. Only swiping the tab will then show the notification center. This has been enough to prevent accidental activation for me so far.
Currently, there is no public API for manipulating the behavior of the notification center. I am of the opinion that it's not likely that an app will ever be able to block a notification's appearance, and only slightly less unlikely that an app would be able to prevent the notification center from appearing. iOS is all about a consistent user experience experience at the price of developer freedom. I could see being frustrated by this kind of functionality if I were an unexpecting user.
All that said, there is always the dark-side of undocumented APIs. I would not be surprised if you could pull off some cleverness using those on a jailbroken device, but that's not my cup-o'-tea.
I just now figured this out. I am developing a game that runs in landscape and whenever I touched the left side, the notification center tab would appear. To fix this, you want to add the following:
setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft
I added this right after I setStatusBarHidden and I no longer have the problem of the notification tab.
Hope that helps.
An API was introduced in iOS 11, alongside a change in behavior to how Notification Center (and Control Center) is presented, to allow you to specify the desired behavior.
UIViewController.preferredScreenEdgesDeferringSystemGestures
In iOS 11+, Notification Center will always pull down when swiping from the very top of the screen, even if the status bar is hidden. preferredScreenEdgesDeferringSystemGestures allows you to specify that swiping a screen edge should not trigger the standard system UI, and instead it will provide a pull-out tab that the user must swipe again to bring out the system UI.
This is intended to be used for games where users swipe frequently, where it would be undesired to bring in system UI instead of control the game. For an immersive app like that, you can return .all to specify you don't want any system UI to appear the first time you swipe any edges of the screen, and it should instead prefer your app's own gestures.
Note that this will disable the ability to swipe once from the bottom to close an app on iPhones and iPads that don't have home buttons - the user will have to swipe twice to close the app.
There is still no way to completely disable Notification Center from within your app, nor prevent notifications from appearing while your app is in the foreground.
I built a very simple code snippet to address this issue programatically. I have a timer set-up in my app delegate that runs every .2 seconds each time it runs it keeps moving the status bar orientation so it doesn't impact the game play. I haven't experienced the annoying notification center in my app since! The only issue is the volume control rotates constantly and might be annoying but it's less annoying than notification center
int tick=0;
-(void)toggleNC
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
tick++;
if (tick==1)
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
}
if (tick==2){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
}
if (tick==3){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
if (tick==4){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown];
tick=0;
}
}