mirror of
https://github.com/defold/extension-iap
synced 2025-06-27 02:17:51 +02:00
Work in progress
This commit is contained in:
parent
257f95f1d3
commit
53ae8a308e
@ -35,6 +35,7 @@ struct IAP
|
||||
int m_ProviderId;
|
||||
|
||||
dmScript::LuaCallbackInfo* m_Listener;
|
||||
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||
|
||||
jobject m_IAP;
|
||||
jobject m_IAPJNI;
|
||||
@ -191,14 +192,23 @@ static int IAP_Restore(lua_State* L)
|
||||
{
|
||||
// TODO: Missing callback here for completion/error
|
||||
// See iap_ios.mm
|
||||
DM_LUA_STACKCHECK(L, 1);
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
iap->m_RestoreListener = 0;
|
||||
}
|
||||
|
||||
if (lua_isfunction(L, 1))
|
||||
{
|
||||
iap->m_RestoreListener = dmScript::CreateCallback(L, 1);
|
||||
}
|
||||
|
||||
int top = lua_gettop(L);
|
||||
JNIEnv* env = Attach();
|
||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Restore, g_IAP.m_IAPJNI);
|
||||
Detach();
|
||||
|
||||
assert(top == lua_gettop(L));
|
||||
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
@ -501,6 +511,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
||||
g_IAP.m_Listener = 0;
|
||||
}
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
}
|
||||
|
||||
if (g_IAP.m_InitCount == 0) {
|
||||
JNIEnv* env = Attach();
|
||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Stop);
|
||||
|
@ -28,6 +28,7 @@ struct IAP
|
||||
bool m_AutoFinishTransactions;
|
||||
NSMutableDictionary* m_PendingTransactions;
|
||||
dmScript::LuaCallbackInfo* m_Listener;
|
||||
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||
IAPCommandQueue m_CommandQueue;
|
||||
IAPCommandQueue m_ObservableQueue;
|
||||
SKPaymentTransactionObserver* m_Observer;
|
||||
@ -599,6 +600,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
||||
g_IAP.m_Listener = 0;
|
||||
}
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
}
|
||||
|
||||
if (g_IAP.m_InitCount == 0) {
|
||||
if (g_IAP.m_PendingTransactions) {
|
||||
[g_IAP.m_PendingTransactions release];
|
||||
|
Loading…
x
Reference in New Issue
Block a user