Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HuaweiPlugin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minhan Jeong
HuaweiPlugin
Commits
f355b68f
Commit
f355b68f
authored
Aug 23, 2021
by
Minhan Jeong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
매개변수 추가
parent
395ab83b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
23 deletions
+80
-23
Hud.uasset
Content/MobileStarterContent/Blueprints/Hud.uasset
+0
-0
HuaweiSDK_UPL.xml
Plugins/HuaweiSDK/Source/HuaweiSDK/HuaweiSDK_UPL.xml
+2
-2
EntryActivity.java
...uaweiSDK/Private/Android/Java/activity/EntryActivity.java
+26
-11
HuaweiIAP.cpp
Plugins/HuaweiSDK/Source/HuaweiSDK/Private/HuaweiIAP.cpp
+42
-8
HuaweiIAP.h
Plugins/HuaweiSDK/Source/HuaweiSDK/Public/HuaweiIAP.h
+10
-2
No files found.
Content/MobileStarterContent/Blueprints/Hud.uasset
View file @
f355b68f
No preview for this file type
Plugins/HuaweiSDK/Source/HuaweiSDK/HuaweiSDK_UPL.xml
View file @
f355b68f
...
@@ -136,9 +136,9 @@
...
@@ -136,9 +136,9 @@
mEntryActivity = new EntryActivity(this);
mEntryActivity = new EntryActivity(this);
}
}
public void AndroidThunkJava_QueryProducts()
public void AndroidThunkJava_QueryProducts(
String[] productIds
)
{
{
mEntryActivity.QueryProducts();
mEntryActivity.QueryProducts(
productIds
);
}
}
public void AndroidThunkJava_Payment(String productId)
public void AndroidThunkJava_Payment(String productId)
...
...
Plugins/HuaweiSDK/Source/HuaweiSDK/Private/Android/Java/activity/EntryActivity.java
View file @
f355b68f
...
@@ -68,36 +68,50 @@ public class EntryActivity extends AppCompatActivity
...
@@ -68,36 +68,50 @@ public class EntryActivity extends AppCompatActivity
});
});
}
}
public
void
QueryProducts
()
public
void
QueryProducts
(
String
[]
ids
)
{
{
List
<
String
>
productIds
=
new
ArrayList
<
String
>();
List
<
String
>
productIds
=
new
ArrayList
<
String
>();
productIds
.
add
(
"rmvw2021_coin_1"
);
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
productIds
.
add
(
"rmvw2021_coin_2"
);
{
productIds
.
add
(
"rmvw2021_coin_3"
);
productIds
.
add
(
ids
[
i
]);
productIds
.
add
(
"rmvw2021_coin_4"
);
}
productIds
.
add
(
"rmvw2021_coin_5"
);
productIds
.
add
(
"rmvw2021_coin_6"
);
IapRequestHelper
.
obtainProductInfo
(
mClient
,
productIds
,
IapClient
.
PriceType
.
IN_APP_CONSUMABLE
,
new
IapApiCallback
<
ProductInfoResult
>()
{
IapRequestHelper
.
obtainProductInfo
(
mClient
,
productIds
,
IapClient
.
PriceType
.
IN_APP_CONSUMABLE
,
new
IapApiCallback
<
ProductInfoResult
>()
{
@Override
@Override
public
void
onSuccess
(
ProductInfoResult
result
)
{
public
void
onSuccess
(
ProductInfoResult
result
)
{
Log
.
i
(
TAG
,
"QueryProductsobtainProductInfo, success"
);
Log
.
i
(
TAG
,
"QueryProductsobtainProductInfo, success"
);
if
(
result
==
null
)
{
if
(
result
==
null
)
{
nativeQueryProductsResult
(
false
);
nativeQueryProductsResult
(
false
,
null
,
null
,
null
);
return
;
return
;
}
}
if
(
result
.
getProductInfoList
()
!=
null
)
{
if
(
result
.
getProductInfoList
()
!=
null
)
{
ArrayList
<
String
>
productIds
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
prices
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
currencyCodes
=
new
ArrayList
<
String
>();
consumableProducts
=
result
.
getProductInfoList
();
consumableProducts
=
result
.
getProductInfoList
();
Log
.
i
(
TAG
,
"consumableProducts->"
+
consumableProducts
.
toArray
().
length
);
Log
.
i
(
TAG
,
"consumableProducts->"
+
consumableProducts
.
toArray
().
length
);
for
(
int
i
=
0
;
i
<
consumableProducts
.
toArray
().
length
;
i
++)
{
ProductInfo
productInfo
=
consumableProducts
.
get
(
i
);
productIds
.
add
(
productInfo
.
getProductId
());
prices
.
add
(
productInfo
.
getPrice
());
currencyCodes
.
add
(
productInfo
.
getCurrency
());
}
}
nativeQueryProductsResult
(
true
);
nativeQueryProductsResult
(
true
,
productIds
.
toArray
(
new
String
[
productIds
.
size
()]),
prices
.
toArray
(
new
String
[
prices
.
size
()]),
currencyCodes
.
toArray
(
new
String
[
currencyCodes
.
size
()]));
}
else
{
nativeQueryProductsResult
(
true
,
null
,
null
,
null
);
}
}
}
@Override
@Override
public
void
onFail
(
Exception
e
)
{
public
void
onFail
(
Exception
e
)
{
Log
.
e
(
TAG
,
"QueryProducts->obtainProductInfo: "
+
e
.
getMessage
());
Log
.
e
(
TAG
,
"QueryProducts->obtainProductInfo: "
+
e
.
getMessage
());
ExceptionHandle
.
handle
(
mActivity
,
e
);
ExceptionHandle
.
handle
(
mActivity
,
e
);
nativeQueryProductsResult
(
false
);
nativeQueryProductsResult
(
false
,
null
,
null
,
null
);
}
}
});
});
}
}
...
@@ -248,6 +262,6 @@ public class EntryActivity extends AppCompatActivity
...
@@ -248,6 +262,6 @@ public class EntryActivity extends AppCompatActivity
}
}
public
native
void
nativeGetIapClientResult
(
boolean
success
);
public
native
void
nativeGetIapClientResult
(
boolean
success
);
public
native
void
nativeQueryProductsResult
(
boolean
success
);
public
native
void
nativeQueryProductsResult
(
boolean
success
,
String
[]
productIds
,
String
[]
priceTexts
,
String
[]
currencyCodes
);
public
native
void
nativePaymentResult
(
String
purchaseToken
,
String
productId
);
public
native
void
nativePaymentResult
(
String
purchaseToken
,
String
productId
);
}
}
\ No newline at end of file
Plugins/HuaweiSDK/Source/HuaweiSDK/Private/HuaweiIAP.cpp
View file @
f355b68f
...
@@ -100,29 +100,63 @@ UHmsQueryProducts::~UHmsQueryProducts()
...
@@ -100,29 +100,63 @@ UHmsQueryProducts::~UHmsQueryProducts()
}
}
}
}
UHmsQueryProducts
*
UHmsQueryProducts
::
QueryProducts
()
UHmsQueryProducts
*
UHmsQueryProducts
::
QueryProducts
(
const
TArray
<
FString
>&
ProductIds
)
{
{
UHmsQueryProducts
*
BPNode
=
NewObject
<
UHmsQueryProducts
>
();
UHmsQueryProducts
*
BPNode
=
NewObject
<
UHmsQueryProducts
>
();
BPNode
->
ProductIds
=
ProductIds
;
s_hmsQueryProductses
.
insert
(
BPNode
);
s_hmsQueryProductses
.
insert
(
BPNode
);
return
BPNode
;
return
BPNode
;
}
}
#if PLATFORM_ANDROID
#if PLATFORM_ANDROID
static
void
ReqQueryProducts
()
static
void
ReqQueryProducts
(
const
TArray
<
FString
>&
ProductIds
)
{
{
if
(
JNIEnv
*
Env
=
FAndroidApplication
::
GetJavaEnv
())
if
(
JNIEnv
*
Env
=
FAndroidApplication
::
GetJavaEnv
())
{
{
static
jmethodID
QueryProductsMethod
=
FJavaWrapper
::
FindMethod
(
Env
,
FJavaWrapper
::
GameActivityClassID
,
"AndroidThunkJava_QueryProducts"
,
"()V"
,
false
);
static
jmethodID
QueryProductsMethod
=
FJavaWrapper
::
FindMethod
(
Env
,
FJavaWrapper
::
GameActivityClassID
,
"AndroidThunkJava_QueryProducts"
,
"(
[Ljava/lang/String;
)V"
,
false
);
if
(
QueryProductsMethod
)
if
(
QueryProductsMethod
)
{
{
UE_LOG
(
LogTemp
,
Log
,
TEXT
(
"Find AndroidThunkJava_QueryProducts"
));
UE_LOG
(
LogTemp
,
Log
,
TEXT
(
"Find AndroidThunkJava_QueryProducts"
));
FJavaWrapper
::
CallVoidMethod
(
Env
,
FJavaWrapper
::
GameActivityThis
,
QueryProductsMethod
);
auto
jProductIds
=
NewScopedJavaObject
(
Env
,
(
jobjectArray
)
Env
->
NewObjectArray
(
ProductIds
.
Num
(),
FJavaWrapper
::
JavaStringClass
,
nullptr
));
for
(
uint32
Param
=
0
;
Param
<
ProductIds
.
Num
();
Param
++
)
{
auto
StringValue
=
FJavaHelper
::
ToJavaString
(
Env
,
ProductIds
[
Param
]);
Env
->
SetObjectArrayElement
(
*
jProductIds
,
Param
,
*
StringValue
);
}
FJavaWrapper
::
CallVoidMethod
(
Env
,
FJavaWrapper
::
GameActivityThis
,
QueryProductsMethod
,
*
jProductIds
);
}
}
}
}
}
}
__attribute__
((
visibility
(
"default"
)))
extern
"C"
void
Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult
(
JNIEnv
*
jenv
,
jobject
thiz
,
jboolean
success
)
__attribute__
((
visibility
(
"default"
)))
extern
"C"
void
Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult
(
JNIEnv
*
jenv
,
jobject
thiz
,
jboolean
success
,
jobjectArray
productIds
,
jobjectArray
priceTexts
,
jobjectArray
currencyCodes
)
{
{
TArray
<
FHmsIapProductInfo
>
ProductInformations
;
if
((
bool
)
success
)
{
jsize
NumProducts
=
jenv
->
GetArrayLength
(
productIds
);
jsize
NumPriceTexts
=
jenv
->
GetArrayLength
(
priceTexts
);
jsize
NumCurrencyCodes
=
jenv
->
GetArrayLength
(
currencyCodes
);
ensure
((
NumProducts
==
NumPriceTexts
)
&&
(
NumProducts
==
NumCurrencyCodes
));
for
(
jsize
Idx
=
0
;
Idx
<
NumProducts
;
Idx
++
)
{
FHmsIapProductInfo
NewProductInfo
;
NewProductInfo
.
ProductId
=
FJavaHelper
::
FStringFromLocalRef
(
jenv
,
(
jstring
)
jenv
->
GetObjectArrayElement
(
productIds
,
Idx
));
NewProductInfo
.
PriceText
=
FJavaHelper
::
FStringFromLocalRef
(
jenv
,
(
jstring
)
jenv
->
GetObjectArrayElement
(
priceTexts
,
Idx
));
NewProductInfo
.
CurrencyCode
=
FJavaHelper
::
FStringFromLocalRef
(
jenv
,
(
jstring
)
jenv
->
GetObjectArrayElement
(
currencyCodes
,
Idx
));
ProductInformations
.
Add
(
NewProductInfo
);
UE_LOG
(
LogTemp
,
Log
,
TEXT
(
"ProductId : %s, PriceText : %s, CurrencyCode : %s"
),
*
NewProductInfo
.
ProductId
,
*
NewProductInfo
.
PriceText
,
*
NewProductInfo
.
CurrencyCode
);
}
}
DECLARE_CYCLE_STAT
(
TEXT
(
"FSimpleDelegateGraphTask.Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult"
),
STAT_FSimpleDelegateGraphTask_Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult
,
STATGROUP_TaskGraphTasks
);
DECLARE_CYCLE_STAT
(
TEXT
(
"FSimpleDelegateGraphTask.Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult"
),
STAT_FSimpleDelegateGraphTask_Java_com_Plugins_HuaweiSDK_activity_EntryActivity_nativeQueryProductsResult
,
STATGROUP_TaskGraphTasks
);
FSimpleDelegateGraphTask
::
CreateAndDispatchWhenReady
(
FSimpleDelegateGraphTask
::
CreateAndDispatchWhenReady
(
FSimpleDelegateGraphTask
::
FDelegate
::
CreateLambda
([
=
]()
FSimpleDelegateGraphTask
::
FDelegate
::
CreateLambda
([
=
]()
...
@@ -132,14 +166,14 @@ __attribute__((visibility("default"))) extern "C" void Java_com_Plugins_HuaweiSD
...
@@ -132,14 +166,14 @@ __attribute__((visibility("default"))) extern "C" void Java_com_Plugins_HuaweiSD
UHmsQueryProducts
*
hmsQueryProducts
=
NewObject
<
UHmsQueryProducts
>
();
UHmsQueryProducts
*
hmsQueryProducts
=
NewObject
<
UHmsQueryProducts
>
();
for
(
std
::
set
<
UHmsQueryProducts
*>::
iterator
it
=
s_hmsQueryProductses
.
begin
();
it
!=
s_hmsQueryProductses
.
end
();
it
++
)
for
(
std
::
set
<
UHmsQueryProducts
*>::
iterator
it
=
s_hmsQueryProductses
.
begin
();
it
!=
s_hmsQueryProductses
.
end
();
it
++
)
{
{
(
*
it
)
->
OnComplete
.
Broadcast
(
true
);
(
*
it
)
->
OnComplete
.
Broadcast
(
true
,
ProductInformations
);
}
}
}
}
else
else
{
{
for
(
std
::
set
<
UHmsQueryProducts
*>::
iterator
it
=
s_hmsQueryProductses
.
begin
();
it
!=
s_hmsQueryProductses
.
end
();
it
++
)
for
(
std
::
set
<
UHmsQueryProducts
*>::
iterator
it
=
s_hmsQueryProductses
.
begin
();
it
!=
s_hmsQueryProductses
.
end
();
it
++
)
{
{
(
*
it
)
->
OnComplete
.
Broadcast
(
false
);
(
*
it
)
->
OnComplete
.
Broadcast
(
false
,
ProductInformations
);
}
}
}
}
...
@@ -155,7 +189,7 @@ __attribute__((visibility("default"))) extern "C" void Java_com_Plugins_HuaweiSD
...
@@ -155,7 +189,7 @@ __attribute__((visibility("default"))) extern "C" void Java_com_Plugins_HuaweiSD
void
UHmsQueryProducts
::
Activate
()
void
UHmsQueryProducts
::
Activate
()
{
{
#if PLATFORM_ANDROID
#if PLATFORM_ANDROID
ReqQueryProducts
();
ReqQueryProducts
(
ProductIds
);
#endif
#endif
}
}
...
...
Plugins/HuaweiSDK/Source/HuaweiSDK/Public/HuaweiIAP.h
View file @
f355b68f
...
@@ -21,6 +21,12 @@ struct FHmsIapProductInfo
...
@@ -21,6 +21,12 @@ struct FHmsIapProductInfo
UPROPERTY
(
BlueprintReadWrite
,
Category
=
ProductInfo
)
UPROPERTY
(
BlueprintReadWrite
,
Category
=
ProductInfo
)
FString
ProductId
;
FString
ProductId
;
UPROPERTY
(
BlueprintReadWrite
,
Category
=
ProductInfo
)
FString
PriceText
;
UPROPERTY
(
BlueprintReadWrite
,
Category
=
ProductInfo
)
FString
CurrencyCode
;
};
};
USTRUCT
(
BlueprintType
)
USTRUCT
(
BlueprintType
)
...
@@ -58,7 +64,7 @@ public:
...
@@ -58,7 +64,7 @@ public:
#pragma endregion
#pragma endregion
#pragma region QueryProducts
#pragma region QueryProducts
DECLARE_DYNAMIC_MULTICAST_DELEGATE_
OneParam
(
FQueryProducts
,
bool
,
IsSucces
s
);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_
TwoParams
(
FQueryProducts
,
bool
,
IsSuccess
,
const
TArray
<
FHmsIapProductInfo
>&
,
AvailablePurchae
s
);
UCLASS
()
UCLASS
()
class
HUAWEISDK_API
UHmsQueryProducts
:
public
UBlueprintAsyncActionBase
class
HUAWEISDK_API
UHmsQueryProducts
:
public
UBlueprintAsyncActionBase
{
{
...
@@ -69,13 +75,15 @@ public:
...
@@ -69,13 +75,15 @@ public:
~
UHmsQueryProducts
();
~
UHmsQueryProducts
();
UFUNCTION
(
BlueprintCallable
,
meta
=
(
BlueprintInternalUseOnly
=
"true"
),
Category
=
"HuaweiIap"
)
UFUNCTION
(
BlueprintCallable
,
meta
=
(
BlueprintInternalUseOnly
=
"true"
),
Category
=
"HuaweiIap"
)
static
UHmsQueryProducts
*
QueryProducts
();
static
UHmsQueryProducts
*
QueryProducts
(
const
TArray
<
FString
>&
ProductIds
);
virtual
void
Activate
()
override
;
virtual
void
Activate
()
override
;
UPROPERTY
(
BlueprintAssignable
)
UPROPERTY
(
BlueprintAssignable
)
FQueryProducts
OnComplete
;
FQueryProducts
OnComplete
;
private
:
TArray
<
FString
>
ProductIds
;
};
};
#pragma endregion
#pragma endregion
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment