QuickBlox / quickblox-android-sdk

QuickBlox Android SDK includes code snippets with main use cases and framework JAR library.
BSD 3-Clause "New" or "Revised" License
417 stars 697 forks source link

Cant set notification to FCM #431

Closed peter-haiduchyk closed 7 years ago

peter-haiduchyk commented 7 years ago

Hello there. Im trying to use qb notifications , but i have problem . Im using sdk 3.3.4 reading from this link to quickblox_developers in documentation i see that we need set QBNotificationChannel for FCM. But we can set only GCM because

public enum QBNotificationChannel {
    GCM("gcm"),
    APNS("apns"),
    APNS_VOIP("apns_voip"),
    EMAIL("email"),
    PULL("pull");

    private String caption;

    private QBNotificationChannel(String caption) {
        this.caption = caption;
    }

    public String toString() {
        return this.caption;
    }

    public String getCaption() {
        return this.caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }
}

dont have FCM. Can any explaine what im doing wrong ? In quickblox admin panel also i dont see settings for FCM , only for GCM. AutoSubscription not working for GCM/FCM. Listener not working. Please any help ? Regards, Peter p.s. sorry for my bad english

RomanPronin commented 7 years ago

Hi, @petergayduchik. You do not need to set QBNotificationChannel manually. Use Auto subscription mechanism. And if you use type FCM, you should set this type in meta-data. Just follow guidelines.

peter-haiduchyk commented 7 years ago

@RomanPronin Hey Roman, thank you for u answer, Im trying to make its without QBNotificationChannel. But its not working . Listener not calling. And in admin panel(Quickblox) i dont see new subscriber with FCM. Please if u guys can help . Can u provide some correct code. Its very urgent.

RomanPronin commented 7 years ago

All code is correct in guide. Did you set QBFcmPushListenerService and QBFcmPushInstanceIDService in manifest file? Do you get some events from QBPushManager.QBSubscribeListener? @petergayduchik, you should look at sample more carefully.

peter-haiduchyk commented 7 years ago

@RomanPronin i dont have any events from QBPushManager. Anythings. FCM NOT WORKING!!! thats all. GCM i can config only for one from two devices. I cant udnderstand why/ Nexus 6.0 not working, Samsung J2 working.

<meta-data android:name="com.quickblox.messages.TYPE" android:value="GCM" />
        <meta-data android:name="com.quickblox.messages.SENDER_ID" android:value="@string/sender_id" />
        <meta-data android:name="com.quickblox.messages.QB_ENVIRONMENT" android:value="DEVELOPMENT" />
        <service
            android:name="com.quickblox.messages.services.gcm.QBGcmPushListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service
            android:name="com.quickblox.messages.services.gcm.QBGcmPushInstanceIDService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>
QBPushManager.getInstance().addListener(new QBPushManager.QBSubscribeListener() {
            @Override
            public void onSubscriptionCreated() {
                Logger.e("################On subscription Created####################");
            }

            @Override
            public void onSubscriptionError(Exception e, int i) {
                Logger.e("########################On subscription error : "+e.toString());
                e.printStackTrace();
            }

            @Override
            public void onSubscriptionDeleted(boolean b) {
                Logger.e("##########################On subscription deleted ,  status = "+b);
            }
        });

all events not call.

peter-haiduchyk commented 7 years ago

any help ? AutoSubscribe not working . GCM hand mode also not working . Subscription going with wrong userId(quickbloxId). If made hand subscribe - in "subscription complete " -> RegistrationID = null.!!

peter-haiduchyk commented 7 years ago

unbelievable, no help with sdk. Documentation for android almost broken. Everything always need repaire to work. Sample apps dont have all classes which need to run. FCM not working, GCM not working. Subscription always destroyed after first push which not received. Admin panel with ajax errors.

after first push which we cant receive (its only problem on android, ios work perfect) and trying send new message we get error in admin panel Error No recipients. At least one user should be subscribed for 'gcm' (through SDK or REST API)

RomanPronin commented 7 years ago

Our SDK and samples work fine. So, our recommendation, if in your code something doesn't work, look at the same implementation in quickblox samples. As for pushes GSM implementation sample https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-pushnotifications, and FCM - https://github.com/QuickBlox/q-municate-android

peter-haiduchyk commented 7 years ago

why u just not reading what im saying ? auto subscription not working . normal subscription work only one time per call and push not received. Callbacks not tell me anything.

peter-haiduchyk commented 7 years ago

today at morning auto subscription make correct registration as i think and we get first push. No changes from our side. What happened idk.

RomanPronin commented 7 years ago

There was temporarily problem with pushes on shared server, sorry about that.

peter-haiduchyk commented 7 years ago

Thank you guys, now all work perfect. @RomanPronin thank for answers. We can close this issue.

RomanPronin commented 7 years ago

You are welcome.

rizwanjillani commented 6 years ago

Android notifications not working

rizwanjillani commented 6 years ago

Android notifications not working below is the logs generated on dashboard

{"notification":{"id":17284994,"badge":null,"device_token":null,"sound":"default","alert":null,"data":{"message":"test","collapse_key":"event25852527"},"expiry":86400,"delivered":false,"delivered_at":null,"failed":true,"failed_at":"2018-09-18T08:44:53+00:00","fail_after":"2018-09-18T09:44:52+00:00","retries":0,"error_code":401,"error_description":"Unable to deliver notification 17284994, received error 401 (Unauthorized, check your App auth_key.)","deliver_after":null,"alert_is_json":null,"app_id":25478,"collapse_key":null,"delay_while_idle":false,"registration_ids":["60772493"],"uri":null,"priority":10,"url_args":null,"category":null,"content_available":false,"mutable_content":false,"notification":null,"type":"Rpush::Client::Redis::Gcm::Notification","event_id":25852527,"event_date":"2018-09-18T08:44:51+00:00"},"log":[{"device_token":null,"delivered_at":null,"failed_at":"2018-09-18T08:44:53+00:00","error_code":401,"error_description":"Unable to deliver notification 17284994, received error 401 (Unauthorized, check your App auth_key.)"}]}

dtaparelli commented 6 years ago

Same here! All configurations checked..

imran-samed commented 5 years ago

@rizwanjillani do you found any solution for this I'm also facing same issue.

Krailit commented 3 years ago

Same here I tried to config everything follows the tutorial. When I send push-notification from the backend I got this log and the client never received any notification.

{ "notification": { "id": 38261720, "badge": null, "device_token": null, "sound": "default", "alert": null, "data": { "message": "fffff7", "collapse_key": "event35665602" }, "expiry": 86400, "delivered": false, "delivered_at": null, "failed": true, "failed_at": "2020-12-16T11:23:11+00:00", "fail_after": "2020-12-16T12:23:11+00:00", "retries": 0, "error_code": 401, "error_description": "Unable to deliver notification 38261720, received error 401 (Unauthorized, check your App auth_key.)", "deliver_after": null, "alert_is_json": null, "sound_is_json": null, "app_id": 66471, "collapse_key": null, "delay_while_idle": false, "registration_ids": [ "eAIn61PQ8PE:APA91bEhMQSq2CztyBzIixPiDpxZn_lTNPECoFN0xupGuCU0L67TYkH9ajIWYF14DDWd601WE0p5RAPvz9XgPFJmendv78zbBsAzkh8jmNby6o-Cc2JBfXYxo_Kiq_zxhVD4_ZtyIeP1" ], "uri": null, "priority": 10, "url_args": null, "category": null, "content_available": false, "dry_run": false, "mutable_content": false, "notification": null, "thread_id": null, "type": "Rpush::Client::Redis::Fcm::Notification", "event_id": 35665602, "event_date": "2020-12-16T11:23:11+00:00" }, "log": [ { "device_token": null, "delivered_at": null, "failed_at": "2020-12-16T11:23:11+00:00", "error_code": 401, "error_description": "Unable to deliver notification 38261720, received error 401 (Unauthorized, check your App auth_key.)" } ] }

But it's working fine if I send push notifications directly from firebase API with the same SERVER_KEY between QB and Postman header.

image