int StoreInit(void(*callback)(int type, int flag, int value, char *desc), char delimiter);

 

Initializes In-App Purchase for your application's store.

 

Return Value

 

Returns one if successful.  Be sure to use the global Store callback specified in StoreInit() to get results from the iTunes Store.

 

Parameters

 

callback

Specifies a global event handler to receive feedback from the iTunes Store.

 

Parameters passed to the callback are:

 

type

Specifies which type of message is being sent back to the client.  Types passed are as follows:

 

Type

Meaning

1

Product Request Event

2

Provide Content Event

3

Record Transaction Event

 

flag

Specifies whether the callback is reporting an error. 0 =  false; 1 = true.

 

value

Specifies the value being reported back to the client.  Varies, depending on the type of reply.

 

desc

Contains a string description relating to the event.  Contains the data pertaining to the requested operation.

 

Remarks

 

StoreInit() initializes the In-App Purchase in your application.  In order to use In-App Purchase, you will need an Apple Developer account with an application defined, and at least one item available for sale in your application.

 

See iTunes Connect for more information on configuring your application for In-App Purchase.

 

Availability

 

Available in DragonFireSDK 2.0 and later.

 

Example

 

#include "DragonFireSDK.h"

 

const char *ErrorNoError(int value)

{

  if (value)

      return("ERROR! ");

  return("");

}

 

void OnStoreEvent(int type,int flag,int value,char *desc)

{

  switch (type)

   {

  case 1: // Product Request

       printf("Product Request event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);

      break;

  case 2: // Provide Content

       printf("Provide Content event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);

      break;

  case 3: // Record Transaction

       printf("Record Transaction event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);

      break;

   }

}

 

int OnButton(int id)

{

  switch (id)

   {

  case 1:

       StorePurchaseProduct("com.mycompany.myapp.my_product_id");

      break;

  case 2:

       StoreRequestProductData("com.mycompany.myapp.my_product_id,com.mycompany.myapp.my_product_id2");

      break;

   }

     

  return(id);

}

 

void AppMain()

{

   StoreInit(OnStoreEvent);

 

   ButtonAdd("Images/Button", 10, 10, OnButton, 1);

   ButtonAdd("Images/Button", 10, 50, OnButton, 2);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}