Browse Source

Android: Updated the code in PushNotifications and InAppPurchases to the recent low-level API changes

tags/2021-05-28
ed 6 years ago
parent
commit
b0e2495eac
2 changed files with 18 additions and 17 deletions
  1. +5
    -5
      modules/juce_gui_extra/native/juce_android_PushNotifications.cpp
  2. +13
    -12
      modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp

+ 5
- 5
modules/juce_gui_extra/native/juce_android_PushNotifications.cpp View File

@@ -191,7 +191,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Bui
//==========================================================================
#if defined(JUCE_FIREBASE_INSTANCE_ID_SERVICE_CLASSNAME)
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
STATICMETHOD (getInstance, "getInstance", "()Lcom/google/firebase/iid/FirebaseInstanceId;") \
METHOD (getToken, "getToken", "()Ljava/lang/String;")
@@ -200,7 +200,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Bui
#endif
#if defined(JUCE_FIREBASE_MESSAGING_SERVICE_CLASSNAME)
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
STATICMETHOD (getInstance, "getInstance", "()Lcom/google/firebase/messaging/FirebaseMessaging;") \
METHOD (send, "send", "(Lcom/google/firebase/messaging/RemoteMessage;)V") \
METHOD (subscribeToTopic, "subscribeToTopic", "(Ljava/lang/String;)V") \
@@ -209,7 +209,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Bui
DECLARE_JNI_CLASS (FirebaseMessaging, "com/google/firebase/messaging/FirebaseMessaging")
#undef JNI_CLASS_MEMBERS
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
METHOD (getCollapseKey, "getCollapseKey", "()Ljava/lang/String;") \
METHOD (getData, "getData", "()Ljava/util/Map;") \
METHOD (getFrom, "getFrom", "()Ljava/lang/String;") \
@@ -223,7 +223,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Bui
DECLARE_JNI_CLASS (RemoteMessage, "com/google/firebase/messaging/RemoteMessage")
#undef JNI_CLASS_MEMBERS
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
METHOD (addData, "addData", "(Ljava/lang/String;Ljava/lang/String;)Lcom/google/firebase/messaging/RemoteMessage$Builder;") \
METHOD (build, "build", "()Lcom/google/firebase/messaging/RemoteMessage;") \
METHOD (constructor, "<init>", "(Ljava/lang/String;)V") \
@@ -235,7 +235,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Bui
DECLARE_JNI_CLASS (RemoteMessageBuilder, "com/google/firebase/messaging/RemoteMessage$Builder")
#undef JNI_CLASS_MEMBERS
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
METHOD (getBody, "getBody", "()Ljava/lang/String;") \
METHOD (getBodyLocalizationArgs, "getBodyLocalizationArgs", "()[Ljava/lang/String;") \
METHOD (getBodyLocalizationKey, "getBodyLocalizationKey", "()Ljava/lang/String;") \


+ 13
- 12
modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp View File

@@ -27,7 +27,7 @@
namespace juce
{
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
METHOD (isBillingSupported, "isBillingSupported", "(ILjava/lang/String;Ljava/lang/String;)I") \
METHOD (getSkuDetails, "getSkuDetails", "(ILjava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Landroid/os/Bundle;") \
METHOD (getBuyIntent, "getBuyIntent", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/os/Bundle;") \
@@ -39,7 +39,7 @@ namespace juce
DECLARE_JNI_CLASS (IInAppBillingService, "com/android/vending/billing/IInAppBillingService")
#undef JNI_CLASS_MEMBERS
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
STATICMETHOD (asInterface, "asInterface", "(Landroid/os/IBinder;)Lcom/android/vending/billing/IInAppBillingService;") \
DECLARE_JNI_CLASS (IInAppBillingServiceStub, "com/android/vending/billing/IInAppBillingService$Stub")
@@ -84,9 +84,10 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
javaString ("com.android.vending.billing.InAppBillingService.BIND").get());
env->CallObjectMethod (intent, AndroidIntent.setPackage, javaString ("com.android.vending").get());
serviceConnection = GlobalRef (CreateJavaInterface (this, "android/content/ServiceConnection").get());
android.activity.callBooleanMethod (JuceAppActivity.bindService, intent,
serviceConnection.get(), 1 /*BIND_AUTO_CREATE*/);
serviceConnection = GlobalRef (CreateJavaInterface (this, "android/content/ServiceConnection"));
env->CallBooleanMethod (getCurrentActivity().get(), AndroidContext.bindService, intent,
serviceConnection.get(), 1 /*BIND_AUTO_CREATE*/);
if (threadPool == nullptr)
threadPool.reset (new ThreadPool (1));
@@ -98,7 +99,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
if (serviceConnection != nullptr)
{
android.activity.callVoidMethod (JuceAppActivity.unbindService, serviceConnection.get());
getEnv()->CallVoidMethod (getCurrentActivity().get(), AndroidContext.unbindService, serviceConnection.get());
serviceConnection.clear();
}
}
@@ -144,8 +145,8 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
auto flagsValues = LocalRef<jobject> (env->CallStaticObjectMethod (JavaInteger, JavaInteger.valueOf, 0));
auto extraFlags = LocalRef<jobject> (env->CallStaticObjectMethod (JavaInteger, JavaInteger.valueOf, 0));
android.activity.callVoidMethod (JuceAppActivity.startIntentSenderForResult, intentSender.get(), requestCode,
fillInIntent.get(), flagsMask.get(), flagsValues.get(), extraFlags.get());
env->CallVoidMethod (getCurrentActivity().get(), AndroidActivity.startIntentSenderForResult, intentSender.get(), requestCode,
fillInIntent.get(), flagsMask.get(), flagsValues.get(), extraFlags.get());
}
else if (responseCode == 7)
{
@@ -325,7 +326,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
//==============================================================================
static LocalRef<jstring> getPackageName()
{
return LocalRef<jstring> ((jstring) (android.activity.callObjectMethod (JuceAppActivity.getPackageName)));
return LocalRef<jstring> ((jstring) (getEnv()->CallObjectMethod (getAppContext().get(), AndroidContext.getPackageName)));
}
//==============================================================================
@@ -339,7 +340,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
const Callback& callbackToUse)
: ThreadPoolJob ("GetProductsInformationJob"),
owner (parent),
packageName (packageNameToUse.get()),
packageName (LocalRef<jobject> (packageNameToUse.get())),
productIdentifiers (productIdentifiersToUse),
callback (callbackToUse)
{}
@@ -509,7 +510,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
const Callback& callbackToUse)
: ThreadPoolJob ("GetProductsBoughtJob"),
owner (parent),
packageName (packageNameToUse.get()),
packageName (LocalRef<jobject> (packageNameToUse.get())),
callback (callbackToUse)
{}
@@ -631,7 +632,7 @@ struct InAppPurchases::Pimpl : private AsyncUpdater,
const Callback& callbackToUse)
: ThreadPoolJob ("ConsumePurchaseJob"),
owner (parent),
packageName (packageNameToUse.get()),
packageName (LocalRef<jobject> (packageNameToUse.get())),
productIdentifier (productIdentifierToUse),
purchaseToken (purchaseTokenToUse),
callback (callbackToUse)


Loading…
Cancel
Save