1

I was opening link in cocos 2d-x (in Previous versions) like:

CCApplication::sharedApplication()->openUrl("http://www.google.com");

A help from this link:

https://github.com/cocos2d/cocos2d-x/pull/4893/files

But in new version openUrl no more exist.

So how can i open links now in new version ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

3

Which OS are you targeting specifically, you can try writing Obj-C code for iOS and put it in

#ifdef (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    NSURL *url = [NSURL URLWithString:@""];  
    [[UIApplication sharedApplication] openURL:url];

    #endif

and add complier flag obj-c and c++ on source file

Similarly, on android you can make JNI call (Java Code)

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("<link>"));
startActivity(browserIntent);

On how to call jni from cocos2d-x http://purplelilgirl.tumblr.com/post/54583532324/code-bit-how-to-use-jni-in-cocos2dx-android

Referred from How can I open a URL in Android's web browser from my application?

Community
  • 1
  • 1
sanchitgulati
  • 456
  • 2
  • 8