Chartboost in Cocos2D-X game - iphone

I used chartboost sdk in cocos2d-x game, I can use below code in appDelegate.m and works great...but there is no c++ call for chart boost. How can I call showInterstitial API from c++ file ?
#define CHARTBOOST_APP_ID =#"Here added valid app id from chart boost account"
#define CHARTBOOST_APP_SIGNATURE #"Here added valid signature from chart boost"
Chartboost *cb = [Chartboost sharedChartboost];
cb.appId = CHARTBOOST_APP_ID;
cb.appSignature = CHARTBOOST_APP_SIGNATURE;
[cb startSession];
[cb showInterstitial];
Is there any c++ version of Chartboost SDK ?
UPDATES:
Simple solution is to use Obj.C version of Chartboost SDK, then use C++ bridge class in .mm file and access it from other .cpp file. Its simple and best way.
Here is Files: Download

There is no C++ version of the Chartboost SDK, however many developers have successfully integrated the SDK in Cocos2d games.
Often they write their own wrapper, but this developer has open sourced his:
http://www.cocos2d-x.org/projects/cocos2d-x/assets/11
https://github.com/wenbin1989/Charboost-x

Chartboost provides SDK for iOS development and Android developement.
So the answer is NO. Right now there's no SDK for C++.

Best and safe way is to write your own Obj.C and C++ bridge class.
Here is files and add objectiveC version of Chartboost sdk in Cocos2dx game

You could do something like this ...
Add this to your AppDelegate.h:
void InitChartBoost();
void ShowInterstitial();
Then create a file AppDelegate.mm and add the following methods:
void AppDelegate::InitChartBoost()
{
id appDelegate = [[UIApplication sharedApplication] delegate];
// Initialize the Chartboost library
[Chartboost startWithAppId:#"your app id"
appSignature:#"your app signature"
delegate:appDelegate];
}
void AppDelegate::ShowInsterstitial()
{
[Chartboost showInterstitial:CBLocationHomeScreen];
}

Related

EKEventStore, do I need EventKit.Framework for iOS 6 separately?

I have an universal iOS app, giving efforts to make it compatible with iOS 6. I am using Cordova / Phonegap framework so my app is HTML, CSS and JS. I am using calenderPlugin for Cordova which is available on GitHub, working fine before iOS 6.
Issue starts here:
Apple added that, from iOS 6 onwards, before doing any operations on calendars and reminders, we need to grant a permission from user. for that here is the sample code:
EKEventStore *eventStore = [[EKEventStore alloc] init];
if( [self checkIsDeviceVersionHigherThanRequiredVersion:#"6.0"] ) {
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted){
//---- codes here when user allow your app to access theirs' calendar.
}else
{
//----- codes here when user NOT allow your app to access the calendar.
}
:
:
}];
}
//**********************************************************************************
// Below is a block for checking is current ios version higher than required version.
//**********************************************************************************
- (BOOL)checkIsDeviceVersionHigherThanRequiredVersion:(NSString *)requiredVersion
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:requiredVersion options:NSNumericSearch] != NSOrderedAscending)
{
return YES;
}
return NO;
}
Of course I have added EventKit.Framework and EventKitUI.Framework. Now the thing is,
for development of iOS 6 I downloaded and installed xCode 4.5 which comes with iOS6 SDK.
xCode does not find out this method requestAccessToEntityType, neither the constant EKEntityTypeEvent is available.
It seems I am missing EventKit.Framework for iOS 6, but how? I have xCode 4.5 which came with SDK for iOS 6. Any suggestions?
Issue Solved,
I have added EventKit.framework by right click on frameworks under project and add files to project. these frameworks was for iOS 5. To add framework for iOS 6, first I removed this frameworks from my frameworks folder and then went to Targets > Summary > Linked Frameworks and Libraries. there I pressed + and added EventKit.framework appearing under iOS 6 folder.
Cheers :-) happy coding.
Check with your BaseSDK, because I have no problem using it in XCode4.5 with iOS6 SDK. I upgrade my XCode 4.5 via App Store, not from development site though.

MonoGame iPhone iPad Setup

I recently migrated a WP7 XNA app to MonoGame. When I build, I get an error saying there is no graphics device manager. Here is the code:
MonoGame.Framework.MacOS > Game.cs
private GraphicsDeviceManager graphicsDeviceManager
{
get
{
if (_graphicsDeviceManager == null)
{
_graphicsDeviceManager = (IGraphicsDeviceManager)
Services.GetService(typeof(IGraphicsDeviceManager));
if (_graphicsDeviceManager == null)
throw new InvalidOperationException ("No Graphics Device Manager");
}
return (GraphicsDeviceManager)_graphicsDeviceManager;
}
}
It appears that my game class never starts. I created a MacOS project for the game. Did I use the incorrect one? I am following these steps to make an iPad / iPhone game: http://www.facepuncher.com/blogs/10parameters/?p=42
If you create a MacOS project it will try and target MacOS. If you have MonoTouch installed you should be able to create an iOS project which will allow you to target iPhone/iPod/iPad.
The instructions from the site you posted are for a MacOS project.
We hope to include MonoGame project templates in the near future.
I hope this helps.

iOS 4 and iOS 5 backward compatibility

I have a question regarding iOS 4 and 5. I am really confused and hope someone will clear it out for me.
I am using iOS 5 SDK in my application. If i use the iOS 5 Twitter integration which is provided by apple, will it run on an iPhone that has iOS 4 installed ?
Does backward compatibility work ?
I have used Twitter as an example, but does backward compatibility really work with iOS 5 ?
If you set up your app properly, so that it can be run on devices running iOS 4 without crashing, then: yes, it will run on an iPhone that has iOS 4 installed.
Your app should implement logic such that the Twitter API is used when the app is being run on an iOS 5 device. When the app is running on an iOS 4 device, you can conditionally choose not to use the Twitter API.
Instead, you can use a different Twitter library (like MGTwitterEngine, or your own) - or just exclude Twitter functionality for those users.
To check whether the TWRequest Class exists, use NSClassFromString.
Class twRequestClass = NSClassFromString(#"TWRequest");
if (twRequestClass == nil) {
// TWRequest does not exist on this device (running iOS version < 5.0)
// ... do something appropriate ...
} else {
TWRequest *twRequest = [[twRequestClass alloc] init];
// ^ I didn't look up the proper initializer, so you should change that line if necessary
// ...
}
You would have to create ifs dependently of the iOS version the user is using. Exemple, in iOS 5 there is an Appearance API to modify most of the UI, but not in iOS 4, so you have to create a little if like that:
// not supported on iOS4
UINavigationBar *navBar = [myNavController navigationBar];
if ([navBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)])
{
[navBar setBackgroundImage:[UIImage imageNamed:#"bg.jpg"] forBarMetrics:UIBarMetricsDefault];
}
If you set up your app properly, so that it can be run on devices running iOS 4, it will crash. This is because you're trying to access methods/features that arn't available.
The way to get around this is to check if a feature is available using
if(NSClassFromString(#"UIPopoverController")) {
// Do something
}
(Popover controller is just an example)
You could also check the version using
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
And then depending on the version run a specific piece of code (i.e. if iOS 5, preform twitter stuff,else do something different)
No, if you use the Twitter APIs available in iOS5, they will not be able to run on iOS4.
The reason being that when app will run on iOS4, the system will not be having the APIs availability.
if you check the documentation, you can see the iOS version from where this Class/API is available.
I hope this helps..

EventKit in Universal app (OS3.2)

I made iPhone app with eventkit framework. However, i upgrade to universal app, app can't run in ipad. I got error message
dyld: Library not loaded: /System/Library/Frameworks/EventKit.framework/EventKit
Yes, event kit only work for iOS 4.0 or later. So, how to make it for universal.
I want to make , if iPad app, don't use event kit framework.
However, I can't add
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
in run time
You need to do two things:
First, weak link against the EventKit framework. You do this in Target->Get Info->General.
Secondly, you need to decide at run time whether or not certain functionality is available:
Class someClass = NSClassFromString(#"SomeClass");
if(someClass) {
// iOS4 code
}
else {
// iOS3.2 code
}
Need to make weak linking.
Right Click on Target -> Get Info -> General Tab
change Eventkit Framework required to weak.
I know this is a really weak answer, but the only answer if you need EventKit on the iPad: Wait until next month when iOS 4.2 ships for the iPad. At this time use the 4.2 beta to develop your universal app. Maybe your app can be ready when the App Store starts accepting apps requiring iOS 4.2.

How do I run a universal app on the iPhone 3.1.3 simulator?

I'm working on a new app that I want to be universal for the iPhone and iPad. I started out with the "Create a Window-based app" wizard, and it created separate app delegates in "iPhone" and "iPad" groups. Since I already was quite familiar with iPhone dev, I did that part of my project, and now I'm ready to do some iPad stuff.
So... I started out by adding a UISplitViewController to my iPad delegate, switch the Active SDK to 3.2, and it works! But when I switch back to 3.1.3, and try to run it in the simulator, Build and Go fails. For starters, I see:
...path.../iPad/AppDelegate_Pad.h:13: error: expected specifier-qualifier-list before 'UISplitViewController'
I've got my Base SDK set to 3.2 and my Deployment Target set to 3.1.3. I thought that was enough. But I also have found in the documentation this method to conditionally compile:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
MyIPadViewController* vc;
// Create the iPad view controller
#else
MyIPhoneViewController* vc;
// Create the iPhone view controller
#endif
So do I need to do this everywhere? It seems like an awful lot of code to add (that I'll be getting rid of in a short time for 4.0 anyway) so I feel like I must be doing something wrong. And, I don't even have any idea how this works for things like #property or #synthesize declarations.
tl;dr version of the question - did I miss a setting somewhere?
I use this C function to help keep the code concise:
BOOL isPad() {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
Another thing I do, when I have different xib files for iPhone vs iPad. I have a stripPadSuffixOnPhone() function that helps keep the code simpler:
// Load/create the Delete table cell with delete button
self.deleteCell = [Utilities loadNib:stripPadSuffixOnPhone(#"DeleteCell~ipad")
ClassName:#"DeleteCell"
Owner:self];
Things like that can make coding more straightforward and a lot less conditionals. Still have to test everything twice though.
Quite the opposite. A universal app runs the same binary on iPhone and iPad so you cannot use conditional compilation to differentiate between the two version. But you need to use the macro Apple cites in the documentation:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad-specific code
} else {
// iPhone-specific code
}
Here's what works for me:
Build your app using SDK 3.2.
Switch the active SDK to iPhone Simulator 3.1.3 (or whatever).
From the Run menu select Debug (not Build and Debug).
The binary built under 3.2 will be installed in the 3.x simulator without rebuilding. When you are finished don't forget to set your active SDK back to 3.2.