dengage-tech / dengage-react-sdk

MIT License
2 stars 3 forks source link

Cannot receive push notification and in-app messages for Huawei device #9

Closed burakakyol closed 2 months ago

burakakyol commented 3 months ago

Hi @hasnainTanvir

We implemented dengage SDK by using Huawei without geofence SDK. Even though my Huawei device was registered dEngage portal correctly, I can't get push notifications or in-app messages on my application. I can receive push notifications when I use Huawei Portal for sending push notifications.

You can see the implementation details and logcat logs below.

package.json

// with Huawei and Firebase without geofence
"@dengage-tech/react-native-dengage": "0.8.8",

build.gradle

classpath 'com.huawei.agconnect:agcp:1.9.1.300' 

app/build.gradle

// with Huawei and Firebase without geofence
    implementation ("com.github.dengage-tech:dengage-android-sdk:6.0.57.1"){
        exclude group: 'com.google.android.play', module:'core'
    }
    ...

        //Huawei Push
    implementation 'com.huawei.hms:push:6.11.0.300'
    implementation 'com.huawei.hms:ads-identifier:3.4.62.300'
    implementation 'com.huawei.hms:ads-installreferrer:3.4.62.300'

AndroidManifest.xml

      <!-- Fcm Messaging Service for handling push messages comes from firebase -->
    <service
        android:name="com.dengage.sdk.push.FcmMessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <!-- Hms Messaging Service for handling push messages comes from huawei messaging service -->

   <service
    android:name="com.dengage.sdk.push.HmsMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
    </intent-filter>
   </service>

    <!-- For handling push notifications comes to messaging service classes -->
    <receiver android:name=".MyReceiver"
        android:exported="false">
    <intent-filter>
        <action android:name="com.dengage.push.intent.RECEIVE" />
        <action android:name="com.dengage.push.intent.OPEN" />
        <action android:name="com.dengage.push.intent.DELETE" />
        <action android:name="com.dengage.push.intent.ACTION_CLICK" />
        <action android:name="com.dengage.push.intent.ITEM_CLICK" />
        <action android:name="com.dengage.push.intent.CAROUSEL_ITEM_CLICK" />
    </intent-filter>
</receiver>

        <meta-data
            android:name="den_event_api_url"
            android:value="https://eu-event.dengage.com" />

        <meta-data
            android:name="den_push_api_url"
            android:value="https://eu-push.dengage.com" />

MainActivity.java

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            setRecentsScreenshotEnabled(false);
        }
        ReactNativeHost reactNativeHost = ((ReactApplication) getApplication()).getReactNativeHost();
        ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();

        DengageRNCoordinator coordinator = DengageRNCoordinator.Companion.getSharedInstance();
        coordinator.injectReactInstanceManager(reactInstanceManager);
        coordinator.setupDengage(
                true, // it is LogStatus & could be true OR false
                getString(R.string.dengage_integration_token), // null in case no firebase key,
                getString(R.string.dengage_huawei_integration_token),
                // NOTE: This is the IntegerationKey Received from dEngage Dashbaord, while create application.
                getApplicationContext()
        );

        // Note: If the app targets API level 23 or higher, the app user must explicitly grant 
        // this permission to the app through a permission management screen. The app requests 
        // the user's approval by sending an intent with action Settings.ACTION_MANAGE_OVERLAY_PERMISSION. 
        // The app can check whether it has this authorization by calling Settings.canDrawOverlays().
        // For API level < 23
        View v = findViewById(android.R.id.content);
        v.setFilterTouchesWhenObscured(true);
        instance = this;

    }

My Device on dEngage Portal image

Logcat Logs

2024-04-03 17:51:48.203 27641-27641 DengageSDK              ma.sisal.superlottery.test           V  Huawei Mobile Services is available
2024-04-03 17:51:48.203 27641-27641 DengageSDK              ma.sisal.superlottery.test           D  Getting Hms Token
2024-04-03 17:51:48.204 27641-27641 DengageSDK              ma.sisal.superlottery.test           D  Getting HMS advertising ID
2024-04-03 17:51:48.462 27641-28749 DengageSDK              ma.sisal.superlottery.test           D  Hms appId is [APP_ID], token is [TOKEN]
2024-04-03 17:51:48.463 27641-28749 DengageSDK              ma.sisal.superlottery.test           V  saveSubscription method is called
2024-04-03 17:51:48.466 27641-28749 DengageSDK              ma.sisal.superlottery.test           D  subscriptionJson: {"advertisingId":"eef4cf01-2d16-4a39-b012-3b6193f1bbce","appVersion":"1.2.6","carrierId":"","contactKey":"","country":"","udid":"ab13d12f-9669-4d50-9e06-03fd395f1d34","integrationKey":"INTEGRATION_KEY","language":"en","partner_device_id":"","permission":true,"sdkVersion":"6.0.57.1","testGroup":"","timezone":"Europe/Istanbul","token":"TOKEN","tokenType":"H","trackingPermission":true}
2024-04-03 17:51:52.469 27641-27641 DengageSDK              ma.sisal.superlottery.test           V  sub method is called
2024-04-03 17:51:52.478 27641-28698 okhttp.OkHttpClient     ma.sisal.superlottery.test           I  --> POST https://eu-push.dengage.com/api/device/subscription
2024-04-03 17:51:52.535 27641-28698 okhttp.OkHttpClient     ma.sisal.superlottery.test           I  <-- 200 https://eu-push.dengage.com/api/device/subscription (55ms)

If there is any wrong configuration in my implementation. Please let me know. Thanks.

hasnainTanvir commented 3 months ago

hello @burakakyol thanks for writing

please place a breakpoint on line number 21 in HmsMessagingService and see if the notification from huawei panel is coming and invoking that class ?

hasnainTanvir commented 3 months ago

please write to me at hasnain.tanvir@dengage.com

burakakyol commented 2 months ago

We can close this task. Thank you @hasnainTanvir