Wintermute Engine Forum

Wintermute Engine => WME Lite => Development => Topic started by: metamorphium on April 04, 2012, 07:32:00 PM

Title: Opening AppStore from WME Lite (iOS feature only)
Post by: metamorphium on April 04, 2012, 07:32:00 PM
Hi muties,

WME lite has a built in capability of in-app purchases. However our publisher decided that they wanted to have two separate version when the lite would open the full version in app store for purchase. For that reason I had to do some modification to sources and I hope Mnemonic will add them to the main build. :wink: :wink:

Without much ado:

changes to ios_utils.h (bold)

Code: WME Script
  1.  
  2.  
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.        
  7.         void IOS_GetDataDir(char* buffer);
  8.         void IOS_ShowStatusLine(int show);
  9.         void IOS_GetDeviceType(char* buffer);
  10.         void IOS_OpenAppleStore(char* ID); // this has been added by me
  11.  
  12. #ifdef __cplusplus
  13. }
  14. #endif
  15.  

changes to ios_utils.m

Code: WME Script
  1. void IOS_OpenAppleStore(char* ID)
  2. {
  3.    
  4.     NSString* nsId = [[NSString alloc] initWithCString: ID];
  5.    
  6.     NSString* targetString = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=";
  7.     targetString = [[targetString stringByAppendingString: nsId] stringByAppendingString:@"&mt=8"];
  8.    
  9.     [nsId release];
  10.    
  11.     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: targetString ]];
  12.  
  13.    
  14. }
  15.  
  16.  

changes to AdGame.cpp

Code: WME Script
  1. // this will need to be added to CAdGame::ScCallMethod if else blocks
  2.  
  3.     else if (strcmp(Name,"OpenAppleStore") == 0) {
  4.         Stack->CorrectParams(1);
  5.         char* AppleStoreId = Stack->Pop()->GetString();
  6.         IOS_OpenAppleStore(AppleStoreId);
  7.         Stack->PushNULL();
  8.         return S_OK;
  9.     }
  10.  
  11.  
  12.  

Also the same file needs to have:

#include "ios_utils.h"

at the top.


The usage in the actual scripts is simple:

Game.OpenAppleStore("123456789"); where the number is your application apple store id.

Hope this helps to someone. :)