GithubHelp home page GithubHelp logo

Comments (76)

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Yes, we plan to add background calls support in one of near release.

from connectycube-flutter-samples.

nguyenquyettienktmt avatar nguyenquyettienktmt commented on July 23, 2024

Yeahhhh, I love U 3000 <3

from connectycube-flutter-samples.

StanevPrime avatar StanevPrime commented on July 23, 2024

+1 for this awesome feature as this is essential for each VoiP App :)

from connectycube-flutter-samples.

najibghadri avatar najibghadri commented on July 23, 2024

Is there a way to implement this with the current API? In a background process for example with the workmanager plugin perhaps?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

hello guys, we updated our Push Notifications documentation for Flutter. You can try use it to implement Push notifications to your Flutter projects before we implement it in our sample.

from connectycube-flutter-samples.

shivanijha002 avatar shivanijha002 commented on July 23, 2024

I am trying to use Push notification for Android however, it is not working as expected.
code sample:
image

Result:
image
image
image

Notification: title and body should not be null. How can I set these values?

Also, I do not get any notification on device. Though message is getting captured in debug console.
If I send dummy message from FCM console, my device do get alert but not from Connectycube 'Push Notifications'-> 'Send' console.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

@shivanijha002

Notification: title and body should not be null. How can I set these values?

For the Android platform, you have to set them to the parameters map, for iOS you can use some additional parameter from our API. Note: ConnectyCube server always sends GCM with 'data' type, not 'notification'.

Also, I do not get any notification on device. Though message is getting captured in debug console.

For Android, it is expected behavior. You have to do it yourself. For example, you can use flutter_local_notifications plugin for it.
For iOS, it is a system feature and the system does it instead of you.

from connectycube-flutter-samples.

shivanijha002 avatar shivanijha002 commented on July 23, 2024

@shivanijha002

Notification: title and body should not be null. How can I set these values?

For the Android platform, you have to set them to the parameters map, for iOS you can use some additional parameter from our API. Note: ConnectyCube server always sends GCM with 'data' type, not 'notification'.

Also, I do not get any notification on device. Though message is getting captured in debug console.

For Android, it is expected behavior. You have to do it yourself. For example, you can use flutter_local_notifications plugin for it.
For iOS, it is a system feature and the system does it instead of you.

Thank you for the details. It might be useful if you can add it in your documentation. I wasted 2 days trying out different things and hoping it will work without anything external.
flutter_local_notifications has worked for me on Android.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@shivanijha002

Notification: title and body should not be null. How can I set these values?

For the Android platform, you have to set them to the parameters map, for iOS you can use some additional parameter from our API. Note: ConnectyCube server always sends GCM with 'data' type, not 'notification'.

Also, I do not get any notification on device. Though message is getting captured in debug console.

For Android, it is expected behavior. You have to do it yourself. For example, you can use flutter_local_notifications plugin for it.
For iOS, it is a system feature and the system does it instead of you.

Thank you for the details. It might be useful if you can add it in your documentation. I wasted 2 days trying out different things and hoping it will work without anything external.
flutter_local_notifications has worked for me on Android.

@shivanijha002

Please, give me suggestion how to get notification using flutter_local_notifications for Push notification.

I got below error:

 Invalid argument(s): Failed to setup background message handler! `onBackgroundMessage`
 should be a TOP-LEVEL OR STATIC FUNCTION and should NOT be tied to a
 class or an anonymous function.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Hello @TatankaConCube

  • How to get pushToken in subscription for push notification?

parameters.pushToken = "2b6f0cc9...4b831186";

  • push token is static or dynamic?

  • deviceId is static or dynamic and also how can I get It?

I get device id is this way using device_info: ^0.4.2+9 package and below method.

Future<String> _getId() async {
    var deviceInfo = DeviceInfoPlugin();
    if (Platform.isIOS) {
      // import 'dart:io'
      var iosDeviceInfo = await deviceInfo.iosInfo;
      return iosDeviceInfo.identifierForVendor; // unique ID on iOS
    } else {
      var androidDeviceInfo = await deviceInfo.androidInfo;
      });
      return androidDeviceInfo.androidId; // unique ID on Android
    }
  }

Is this right way or I have to implement other method?

  • When I send notification It registerd on dashboard but it displays in falied status.

So, help me to solve this issue.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

How to get pushToken in subscription for push notification?

you have to use flutter plugins for this, in our documentation, we provided the needed code for this.

push token is static or dynamic?

it can be changed during the app work, please, see our documentation, how to get the current token, and how to subscribe to its changes.

deviceId is static or dynamic and also how can I get It?

it is a static unique identifier for your device on the ConnectyCube server. You provided the correct code for getting it.

When I send notification It registerd on dashboard but it displays in falied status.

need more details about this issue:

  • which error present in failed log?
  • have some receivers subscription in the Connectycube admin panel?
  • for which platform (Android or iOS) do you send notification?
  • how you send notification (via API from app or from Admin panel)?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube
- which error present in failed log?

W/System.err( 4415): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.ClipData.getItemCount()' on a null object reference
W/System.err( 4415):    at android.os.Parcel.readException(Parcel.java:1626)
W/System.err( 4415):    at android.os.Parcel.readException(Parcel.java:1573)
W/System.err( 4415):    at android.content.IClipboard$Stub$Proxy.getPrimaryClip(IClipboard.java:197)
W/System.err( 4415):    at android.content.ClipboardManager.getPrimaryClip(ClipboardManager.java:247)
W/System.err( 4415):    at io.flutter.plugin.platform.PlatformPlugin.getClipboardData(PlatformPlugin.java:283)
W/System.err( 4415):    at io.flutter.plugin.platform.PlatformPlugin.access$700(PlatformPlugin.java:24)
W/System.err( 4415):    at io.flutter.plugin.platform.PlatformPlugin$1.getClipboardData(PlatformPlugin.java:82)
W/System.err( 4415):    at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:141)
W/System.err( 4415):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/System.err( 4415):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err( 4415):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
W/System.err( 4415):    at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 4415):    at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err( 4415):    at android.os.Looper.loop(Looper.java:143)
W/System.err( 4415):    at android.app.ActivityThread.main(ActivityThread.java:7224)
W/System.err( 4415):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 4415):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
W/System.err( 4415):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Screenshot (9)
Screenshot (10)
Screenshot (11)

Failed notification log :
{"notification":{"id":6382549,"badge":null,"device_token":null,"sound":"default","alert":null,"data":{"message":"jhfgjhbn","custom_parameter1":"FLUTTER_NOTIFICATION_CLICK","custom_parameter2":"custom parameter value 2","collapse_key":"event3072823"},"expiry":86400,"delivered":false,"delivered_at":null,"failed":true,"failed_at":"2020-10-22T09:16:38+00:00","fail_after":"2020-10-22T10:16:32+00:00","retries":0,"error_code":null,"error_description":"Unable to deliver notification 6382549, received error (Failed to deliver to all recipients. Errors: InvalidRegistration.)","deliver_after":null,"alert_is_json":null,"app_id":1246,"collapse_key":null,"delay_while_idle":false,"registration_ids":["2206393...2206393"],"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":3072823,"event_date":"2020-10-22T09:16:31+00:00"},"log":[{"device_token":null,"delivered_at":null,"failed_at":"2020-10-22T09:16:38+00:00","error_code":null,"error_description":"Unable to deliver notification 6382549, received error (Failed to deliver to all recipients. Errors: InvalidRegistration.)"}]}

- have some receivers subscription in the Connectycube admin panel?
Yes.
Screenshot (8)

- for which platform (Android or iOS) do you send notification?
Android

- how you send notification (via API from app or from Admin panel)?
I follow step to integrate notification.

I want to send send using firebase with your dashboard.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Hello @TatankaConCube

I want to use notification functionality in chat application. I implemented this functionality using your connectycube_sdk package. I follow each and every steps to do this functionality and also I successfully implemented this functionality. But in this code I face one issue is that when user is offline or not in the dialog page I can't get notification. In terminal there is no any error display. Every API from your server is called successfully and it displays log of generated notification. When I push on send button notification generates which displays in connecty_cube dashboard. Also device is registered in Push Notification -> Device subscription panel. Every notification displays in Push Notification -> Queue panel. but in this panel Start date, End date, Period are not displayed. When I click on status I get this issue in log received error (Failed to deliver to all recipients. Errors: InvalidRegistration). So I can't get receiver for notification. I use android device for notification. I also link my application with firebase, but in firebase console -> cloud messaging there is no any data display for notification. Please help me to solve this issue asap. I also displays image in above comment. Please check it.

this is log.

I/flutter (23928): CB-SDK: : =========================================================
I/flutter (23928): === REQUEST ==== 4950eb17-f364-421a-9a5e-50a8fca32438 ===
I/flutter (23928): REQUEST
I/flutter (23928):   GET https://api.connectycube.com/chat/Dialog/5f897318ca8bf43be78fc7c3/notifications
I/flutter (23928): HEADERS
I/flutter (23928):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.0, CB-Token: 0c329ee573ed050c6cd83255180318651c000d91}
I/flutter (23928): BODY
I/flutter (23928):
I/flutter (23928):
I/flutter (23928): pushToken======2206408...2206393
I/flutter (23928): === REQUEST ==== ebf91f59-d7b9-4c9f-a7c5-3cb3f128537e ===
I/flutter (23928): REQUEST
I/flutter (23928):   POST https://api.connectycube.com/subscriptions
I/flutter (23928): HEADERS
I/flutter (23928):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.0, CB-Token: 0c329ee573ed050c6cd83255180318651c000d91}
I/flutter (23928): BODY
I/flutter (23928):   {"notification_channel":"gcm","device":{"udid":"e1f422d058f5ec16","platform":"android"},"push_token":{"environment":"development","client_identificatio
n_sequence":"2206408...2206393"}}
I/flutter (23928):
I/flutter (23928): CB-SDK: : {parameters: {message: jhfgjhbn, custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_parameter2: custom parameter value 2, ios_voip: 1}, noti
ficationType: push, environment: development, eventType: null, usersIds: [2206393, 2206408], externalUsersIds: [], usersTagsAll: [], usersTagsAny: [], usersTagsExclude: [],
 date: null, endDate: null, period: null, name: null}
I/flutter (23928): CB-SDK: : =========================================================
I/flutter (23928): === REQUEST ==== 8a349d32-3840-4564-806a-e672bd7c3a5f ===
I/flutter (23928): REQUEST
I/flutter (23928):   POST https://api.connectycube.com/events
I/flutter (23928): HEADERS
I/flutter (23928):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.0, CB-Token: 0c329ee573ed050c6cd83255180318651c000d91}
I/flutter (23928): BODY
I/flutter (23928):   {"event":{"notification_type":"push","environment":"development","message":"eyJtZXNzYWdlIjoiamhmZ2poYm4iLCJjdXN0b21fcGFyYW1ldGVyMSI6IkZMVVRURVJfTk9USUZ
JQ0FUSU9OX0NMSUNLIiwiY3VzdG9tX3BhcmFtZXRlcjIiOiJjdXN0b20gcGFyYW1ldGVyIHZhbHVlIDIiLCJpb3Nfdm9pcCI6MX0=","user":{"ids":"2206393,2206408"}}}
I/flutter (23928):
I/flutter (23928): CB-SDK: : onSendMessage message= {_id: 5f92a61cd8755caca57ed8a0, chat_dialog_id: null, message: ytt, date_sent: 1603446300, sender_id: null, recipient_id
: null, read_ids: null, delivered_ids: null, views_count: null, attachments: null, id: null, created_at: null, updated_at: null}
I/flutter (23928): sending: <message id="5f92a61cd8755caca57ed8a0" type="chat" to="[email protected]">
I/flutter (23928):   <body>ytt</body>
I/flutter (23928):   <extraParams xmlns="jabber:client">
I/flutter (23928):     <date_sent>1603446300</date_sent>
I/flutter (23928):     <save_to_history>1</save_to_history>
I/flutter (23928):     <dialog_id>5f897318ca8bf43be78fc7c3</dialog_id>
I/flutter (23928):   </extraParams>
I/flutter (23928):   <markable xmlns="urn:xmpp:chat-markers:0"/>
I/flutter (23928): </message>
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): markAsReadIfNeed message= {_id: 5f9299a4745a45347ae9af28, chat_dialog_id: 5f897318ca8bf43be78fc7c3, message: hello, date_sent: 1603443108, sender_id: 220
6408, recipient_id: 2206393, read_ids: [2206408, 2206393], delivered_ids: [2206408, 2206393], views_count: 0, attachments: [], id: null, created_at: 2020-10-23 08:51:48.000
Z, updated_at: 2020-10-23 09:44:49.000Z}, isOpponentMsgRead= true
D/InputMethodManager(23928): prepareNavigationBarInfo() DecorView@a03dc7[MainActivity]
D/InputMethodManager(23928): getNavigationBarColor() -855310
V/InputMethodManager(23928): Starting input: tba=com.example.chatconnectycubesdk ic=io.flutter.plugin.editing.InputConnectionAdaptor@d0fd6ee mNaviBarColor -855310 mIsGetNav
iBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager(23928): startInputInner - Id : 0
I/InputMethodManager(23928): startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport(23928): Input channel constructed: fd=110
D/InputTransport(23928): Input channel destroyed: fd=99
W/IInputConnectionWrapper(23928): getExtractedText on inactive InputConnection
I/chatty  (23928): uid=10310(com.example.chatconnectycubesdk) identical 1 line
W/IInputConnectionWrapper(23928): getExtractedText on inactive InputConnection
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): markAsReadIfNeed message= {_id: 5f927bbc383c35711b8cfe37, chat_dialog_id: 5f897318ca8bf43be78fc7c3, message: hiii, date_sent: 1603435452, sender_id: 2206
408, recipient_id: 2206393, read_ids: [2206408, 2206393], delivered_ids: [2206408, 2206393], views_count: 0, attachments: [], id: null, created_at: 2020-10-23 06:44:13.000Z
, updated_at: 2020-10-23 06:44:19.000Z}, isOpponentMsgRead= true
I/flutter (23928): List Length ======>>>>>> 6
I/flutter (23928): CB-SDK: : *********************************************************
I/flutter (23928): *** RESPONSE *** 201 *** ebf91f59-d7b9-4c9f-a7c5-3cb3f128537e ***
I/flutter (23928): HEADERS
I/flutter (23928):   {connection: keep-alive, cache-control: max-age=0, private, must-revalidate, set-cookie: _mkra_ctxt=a1b03485c8ab6e70df32f38b2d58c279--201; path=/; max-
age=5; HttpOnly; secure, status: 201 Created, transfer-encoding: chunked, date: Fri, 23 Oct 2020 09:44:57 GMT, access-control-allow-origin: *, strict-transport-security: ma
x-age=31536000,max-age=15768000;, content-type: application/json; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: b210adc3-c7a3-4049-b05
d-1e4d607bdad1, cb-token-expirationdate: 2020-10-23 11:44:27 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.027089, etag: W/"27aa6142f05dbd6d4d2105b5149448e5", x-f
rame-options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter (23928): BODY
I/flutter (23928):   [{"subscription":{"id":442885,"device":{"udid":"e1f422d058f5ec16","client_identification_sequence":"2206408...2206393","platform":{"name":"android"},"b
undle_identifier":null},"notification_channel":{"name":"gcm"}}}]
I/flutter (23928):
I/flutter (23928): SUBSCRIPTION SUCCESS ====> [{notification_channel: gcm, push_token: null, device: {udid: e1f422d058f5ec16, platform: android}}]
I/flutter (23928): sending: <r xmlns="urn:xmpp:sm:3"/>
I/flutter (23928): CB-SDK: : *********************************************************
I/flutter (23928): *** RESPONSE *** 200 *** 4950eb17-f364-421a-9a5e-50a8fca32438 ***
I/flutter (23928): HEADERS
I/flutter (23928):   {connection: keep-alive, cache-control: max-age=0, private, must-revalidate, set-cookie: _mkra_ctxt=cb3191b803a445004f859dd28cd42e06--200; path=/; max-
age=5; HttpOnly; secure, status: 200 OK, transfer-encoding: chunked, date: Fri, 23 Oct 2020 09:44:57 GMT, access-control-allow-origin: *, strict-transport-security: max-age
=31536000,max-age=15768000;, content-type: application/json; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: 7639f729-d822-4296-8dc0-41b
7f1362303, cb-token-expirationdate: 2020-10-23 11:44:27 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.020983, etag: W/"f18ac01a1af2e0e9da770f90521f6336", x-frame-
options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter (23928): BODY
I/flutter (23928):   {"notifications":{"enabled":1}}
I/flutter (23928):
I/flutter (23928): NOTIFICATION ENABLE ==> true
I/flutter (23928): CB-SDK: : *********************************************************
I/flutter (23928): *** RESPONSE *** 201 *** 8a349d32-3840-4564-806a-e672bd7c3a5f ***
I/flutter (23928): HEADERS
I/flutter (23928):   {connection: keep-alive, cache-control: max-age=0, private, must-revalidate, set-cookie: _mkra_ctxt=e6706b5c9bf4f8206601a71b07ff5e42--201; path=/; max-
age=5; HttpOnly; secure, status: 201 Created, transfer-encoding: chunked, date: Fri, 23 Oct 2020 09:44:57 GMT, access-control-allow-origin: *, strict-transport-security: ma
x-age=31536000,max-age=15768000;, content-type: application/json; charset=utf-8, x-xss-protection: 1; mode=block, server: nginx/1.16.1, x-request-id: bd9580bd-bb06-4843-a65
a-bbcbd8680f27, cb-token-expirationdate: 2020-10-23 11:44:27 UTC, connectycube-rest-api-version: 0.1.1, x-runtime: 0.114506, etag: W/"e030cb2767d2eab406427c8910da6753", x-f
rame-options: SAMEORIGIN, x-content-type-options: nosniff}
I/flutter (23928): BODY
I/flutter (23928):   [{"event":{"id":3154266,"event_type":"one_shot","message":"data.message=amhmZ2poYm4=\u0026data.custom_parameter1=RkxVVFRFUl9OT1RJRklDQVRJT05fQ0xJQ0s=\u
0026data.custom_parameter2=Y3VzdG9tK3BhcmFtZXRlcit2YWx1ZSsy","date":null,"period":null,"name":null,"occured_count":0,"created_at":"2020-10-23T09:44:57Z","updated_at":"2020-
10-23T09:44:57Z","end_date":null,"active":true,"application_id":3473,"user_id":2206393,"kind":"ChatAlert","environment":"development","tag_query":null,"notification_channel
":{"name":"gcm"}}}]
I/flutter (23928):
I/flutter (23928): CUBE EVENT -----> [{notification_type: null, environment: development, message: {message: jhfgjhbn, custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom
_parameter2: custom parameter value 2}, event_type: one_shot}]
I/flutter (23928): response: <a xmlns='urn:xmpp:sm:3' h='9'/>
I/flutter (23928): !!!!handle response <xmpp_stone><a xmlns='urn:xmpp:sm:3' h='9'/></xmpp_stone>
I/flutter (23928): !!!!!!! PARSED<xmpp_stone><a xmlns='urn:xmpp:sm:3' h='9'/></xmpp_stone>
I/flutter (23928): Delivered: NPFMPIMRU
I/flutter (23928): Delivered: UIXNVLBFW
I/flutter (23928): Delivered: LFEEJHOVX
I/flutter (23928): Delivered: 5f92a61cd8755caca57ed8a0

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

There are descriptions of possible errors on sending push notifications from Connectycube server to FCM. Looks like you have the wrong (or expired) token in the subscription. Try delete the subscription from the admin panel and create a new one, then try to send push notification again.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

There are descriptions of possible errors on sending push notifications from Connectycube server to FCM. Looks like you have the wrong (or expired) token in the subscription. Try delete the subscription from the admin panel and create a new one, then try to send push notification again.

Hello @TatankaConCube
Please check log which is updated in above comment.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

And you get the same error again? Right?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

And you get the same error again? Right?

Yes

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Did you configure the required tokens in the ConnectyCube admin console? Did you add google-services.json file to your Android project?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Did you configure the required tokens in the ConnectyCube admin console? Did you add google-services.json file to your Android project?

  • Yes, I configure all require token in ConnectyCube admin console.

  • Yes, I add google-services.json file in Android Project.

This is my google-services.json file.

{
  "project_info": {
    "project_number": "948024062720",
    "firebase_url": "https://chatconnectycube-b3b85.firebaseio.com",
    "project_id": "chatconnectycube-b3b85",
    "storage_bucket": "chatconnectycube-b3b85.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:948024062720:android:f14a8bcb7bc30bb09eb9e5",
        "android_client_info": {
          "package_name": "com.example.chatconnectycubesdk"
        }
      },
      "oauth_client": [
        {
          "client_id": "948024062720-9le85u800fbqtd1gkbrmpv584bg20mvt.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.example.chatconnectycubesdk",
            "certificate_hash": "b81d0c07036f1cbdc7e4483e8cba343f80ca4682"
          }
        },
        {
          "client_id": "948024062720-bjjnaig93fjasb7qctjgf3ftphum6cdb.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AIzaSyBAKCSyeIhx-li2zBz4HOdF4xirAaoAyFY"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "948024062720-bjjnaig93fjasb7qctjgf3ftphum6cdb.apps.googleusercontent.com",
              "client_type": 3
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

@TatankaConCube

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

hmm, it is strange (((
can you try to use another plugin for getting a token from the Android system?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

hmm, it is strange (((
can you try to use another plugin for getting a token from the Android system?

@TatankaConCube

  • I get device Id using device_info plugin.
    This way I get deviceId
String dId = '';

  Future<String> _getId() async {
    var deviceInfo = DeviceInfoPlugin();
    if (Platform.isIOS) {
      // import 'dart:io'
      var iosDeviceInfo = await deviceInfo.iosInfo;
      setState(() {
        dId = iosDeviceInfo.identifierForVendor;
        print('IOS:::::::' + dId);
      });
      return iosDeviceInfo.identifierForVendor; // unique ID on iOS
    } else {
      var androidDeviceInfo = await deviceInfo.androidInfo;
      setState(() {
        dId = androidDeviceInfo.androidId;
        print('Android:::::::' + dId);
      });
      return androidDeviceInfo.androidId; // unique ID on Android
    }
  }
  • This is subscription() method snippet which call message send time.
Future<void> subScription() async {
    bool isProduction = bool.fromEnvironment('dart.vm.product');

    CreateSubscriptionParameters parameters = CreateSubscriptionParameters();
    parameters.environment =
        isProduction ? CubeEnvironment.PRODUCTION : CubeEnvironment.DEVELOPMENT;

    if (Platform.isAndroid) {
      parameters.channel = NotificationsChannels.GCM;
      parameters.platform = CubePlatform.ANDROID;
    } else if (Platform.isIOS) {
      parameters.channel = NotificationsChannels.APNS;
      parameters.platform = CubePlatform.IOS;
    }

    String token = await _fcm.getToken();

    String deviceId = dId;
    parameters.udid = deviceId;
    print(
        'pushToken======/*$token*/ ${_cubeDialog.getRecipientId()}...${_cubeDialog.userId}');
    parameters.pushToken =
        '${_cubeDialog.getRecipientId()}...${_cubeDialog.userId}'; /*"2b6f0cc9...4b831186";*/
    parameters.bundleIdentifier =
        ""; 

    createSubscription(parameters.getRequestParameters())
        .then((cubeSubscription) {
      print('SUBSCRIPTION SUCCESS ====> $cubeSubscription');
    }).catchError((error) {
      print('SUBSCRIPTION ERROR ==> $error');
    });
  }
  • This is my sendNotification() method
void sendPushNotification() {
    bool isProduction = bool.fromEnvironment('dart.vm.product');
    CreateEventParams params = CreateEventParams();
    params.parameters = {
      'message': 'jhfgjhbn',
      // 'message' field is required"Some message in push"
      'custom_parameter1': 'FLUTTER_NOTIFICATION_CLICK',
      //"custom parameter value 1"
      'custom_parameter2': "custom parameter value 2",
      'ios_voip': 1
      // to send VoIP push notification to iOS
      //more standard parameters you can found by link https://developers.connectycube.com/server/push_notifications?id=universal-push-notifications
    };

    params.notificationType = NotificationType.PUSH;
    params.environment =
        isProduction ? CubeEnvironment.PRODUCTION : CubeEnvironment.DEVELOPMENT;
    params.usersIds = [_cubeDialog.userId, _cubeDialog.getRecipientId()];

    createEvent(params.getEventForRequest()).then((cubeEvent) {
      print('CUBE EVENT -----> $cubeEvent');
    }).catchError((error) {
      print('CUBE EVENT ERROR -----> $error');
    });
  }
  • This is getToken() method
void getToken() {
   final connector = createPushConnector();
   if (connector.token.value != null) {
     String token = connector.token.value;
     print('Exist token: $token');
   } else {
     connector.token.addListener(() {
       String token = connector.token.value;
       print('Updated token: $token');
     });
   }
 }
  • This is init() method

void init() async {
final connector = createPushConnector();

connector.configure(
    onLaunch: onLaunch,
    onMessage: onMessage,
    onResume: onResume,
    onBackgroundMessage: onBackgroundMessage);

connector.requestNotificationPermissions();

getToken();

}


-```
 // Called when your app launched by PushNotifications

  Future<dynamic> onLaunch(Map<String, dynamic> message) {
    log('onLaunch, message: $message');
    return Future.value();
  }

// Called when your app become foreground from background by PushNotifications

Future onResume(Map<String, dynamic> message) {
log('onResume, message: $message');
return Future.value();
}


- ```
// Called when receive PushNotifications during your app is on foreground

  Future<dynamic> onMessage(Map<String, dynamic> message) {
    log('onMessage, message: $message');
    return Future.value();
  }

// Called when receive PushNotifications when app was stopped (Android only).

static Future onBackgroundMessage(Map<String, dynamic> message) {
log('onBackgroundMessage, message: $message');
if (message.containsKey('data')) {
// Handle data message
final dynamic data = message['data'];
}

if (message.containsKey('notification')) {
  // Handle notification message
  final dynamic notification = message['notification'];
}

// Or do other work.
return Future.value();

}


- This is the code snippet which I use for notification. If I made any mistake then Please suggest me asap. 

I can't get token in **getToken()** method. I think this is the main issue. How can I solve this?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Yes, sure, it is the main problem. But I do not understand, which token you used before for creating a subscription?
Which version of flutter_apns plugin do you use? or just from GitHub like in our documentation?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

flutter_apns plugin depends on firebase_messaging plugin, please read its Readme and add needed configs to your project.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

Yes, sure, it is the main problem. But I do not understand, which token you used before for creating a subscription?

I use this method for getting token

if (connector.token.value != null) {
    String token = connector.token.value;
    log('Exist token: $token');
  } else {
    connector.token.addListener(() {
      String token = connector.token.value;
      log('Updated token: $token');
    });
  }

Which version of flutter_apns plugin do you use? or just from GitHub like in our documentation?

I use flutter_apns: ^1.3.1.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

flutter_apns plugin depends on firebase_messaging plugin, please read its Readme and add needed configs to your project.

Dear @TatankaConCube

I already done all this requirement. I have only one confusion for this this plugin. Should I have to mention below method which is given in firebase_messaging documentation?

firebase_messaging

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

I can't get token in getToken() method.

how you created subscriptions before without this method? Whit token you used?

Should I have to mention below method which is given in firebase_messaging documentation?

No, you don't need this method, it is just an example, how to send push notification from the app. Our server does similar logic when you create an event or send a push notification from the ConnectyCube admin panel. But you can use it for testing push notifications on your device without the Connectycube server.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

how you created subscriptions before without this method?

I use in all above method in this way. If I made mistake then suggest me.

void onSendChatMessage(String content) async {
    await notificationEnable();
    if (content.trim() != '') {
      final message = createCubeMsg();
      message.body = content.trim();
      await subScription();
      await init();

      sendPushNotification();
      onSendMessage(message);
    } else {
      Fluttertoast.showToast(msg: 'Nothing to send');
    }
  }

Whit token you used?

Now, I get token in init() method.

  • In init() method I use token
if (connector.token.value != null) {
      String token = connector.token.value;
      print('Exist token: $token');
    } else {
      connector.token.addListener(() {
        String token = connector.token.value;
        print('Updated token: $token');
      });
  • In subscription() method, I use this token

parameters.pushToken = '${_cubeDialog.getRecipientId()}...${_cubeDialog.userId}';

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Try to clear all app data, then completely remove it from the device and install it again. During writing documentation, I did the same step by step and it worked. I can't understand why it does not work for you (((

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

parameters.pushToken it is 'key', which FCM uses for identifying your device. It is like 'receiverId' for FCM when the Connectycube server sends push notifications. It should be the only token from the system, but not any random data.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

parameters.pushToken it is 'key', which FCM uses for identifying your device. It is like 'receiverId' for FCM when the Connectycube server sends push notifications. It should be the only token from the system, but not any random data.

@TatankaConCube
But sir I did not know hoe to get this 'key', I mean 'receiverId'. Actually, I mean where I can get this?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

In our example it is the method getToken(). You can try to use another plugins for getting this data.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

In our example it is the method getToken(). You can try to use another plugins for getting this data.

@TatankaConCube
I check full code but I can't find getToken() method. Please suggest me which plugin I should use for getting this data.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

I mean this part from our doc

// getting token which used for subscription on Push Notifications on ConnectyCube server
  if (connector.token.value != null) {
    String token = connector.token.value;
    log('Exist token: $token');
  } else {
    connector.token.addListener(() {
      String token = connector.token.value;
      log('Updated token: $token');
    });
  }

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

I tried everything but I didn't get any solution. If you have demo file of notification code snippet then please share.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

@Significantinfotech2020 during writing the documentation I used this draft branch for testing. There part of code related to creation subscription. You can try to add something similar to your project.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@Significantinfotech2020 during writing the documentation I used this draft branch for testing. There part of code related to creation subscription. You can try to add something similar to your project.

@TatankaConCube

I tried as you suggest, but now I got this error log from dashboard notification.

{
  "notification": {
    "id": 6901158,
    "badge": null,
    "device_token": null,
    "sound": "default",
    "alert": null,
    "data": {
      "message": "dt7vh",
      "custom_parameter1": "FLUTTER_NOTIFICATION_CLICK",
      "custom_parameter2": "custom parameter value 2",
      "collapse_key": "event3372039"
    },
    "expiry": 86400,
    "delivered": false,
    "delivered_at": null,
    "failed": true,
    "failed_at": "2020-10-26T10:33:52+00:00",
    "fail_after": "2020-10-26T11:33:42+00:00",
    "retries": 0,
    "error_code": null,
    "error_description": "Unable to deliver notification 6901158, received error (Failed to deliver to recipients 0, 1. Errors: InvalidRegistration, InvalidRegistration.)",
    "deliver_after": null,
    "alert_is_json": null,
    "app_id": 1283,
    "collapse_key": null,
    "delay_while_idle": false,
    "registration_ids": [
      "ad156f91103bd48a",
      "e1f422d058f5ec16",
      "d4doPAAuTUm2c6jfr-I-PM:APA91bFgD55qnOoYAk74GV5aIR6dHIMKaY4Pbz-319cY7aTjVKDcrycw7agET9I4cOwxQcfMs7uYJ38i2QAzXEjDPdOmyYbqL62kJ06OnIyq9fCcvvGuKJ9WiJMnezdX8JlXEQXkHHcP",
      "ezAU2ZFgRZuuicqM9C7bTi:APA91bGPXBBtbdi5_MFSfMkOZQ80FaBlfUa-mOrh3R4jFL0XkQDcM3YAF8kqdH31XnKG75XEuZ4mFV2NR-e162QPm6mwt_3JguRohA8fARk_VOXo4rOA40MKqkEEsVbzGhLbxAZpOvzT"
    ],
    "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": 3372039,
    "event_date": "2020-10-26T10:33:42+00:00"
  },
  "log": [
    {
      "device_token": null,
      "delivered_at": null,
      "failed_at": "2020-10-26T10:33:52+00:00",
      "error_code": null,
      "error_description": "Unable to deliver notification 6901158, received error (Failed to deliver to recipients 0, 1. Errors: InvalidRegistration, InvalidRegistration.)"
    }
  ]
}

Now, If you catch exact problem, then help me asap.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Can you get a token from FCM on the device now? Can you provide logs with the subscription creation process? Looks like you have the same error as before.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

Can you get a token from FCM on the device now?

Yes, but in firebase console when I clicked on cloud messaging tab, It has no any send notification.

Can you provide logs with the subscription creation process?

I/flutter (31956): CB-SDK: : =========================================================
I/flutter (31956): === REQUEST ==== baa7ccb0-2ad5-49b0-ae9c-2f599e13cecc ===
I/flutter (31956): REQUEST
I/flutter (31956):   POST https://api.connectycube.com/subscriptions
I/flutter (31956): HEADERS
I/flutter (31956):   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 0.5.0, CB-Token: eb0d292af15156876556be15d5d162eeac000dd4}
I/flutter (31956): BODY
I/flutter (31956):   {"notification_channel":"gcm","device":{"udid":"ad156f91103bd48a","platform":"android"},"push_token":{"environment":"development","client_identificatio
n_sequence":"d4doPAAuTUm2c6jfr-I-PM:APA91bFgD55qnOoYAk74GV5aIR6dHIMKaY4Pbz-319cY7aTjVKDcrycw7agET9I4cOwxQcfMs7uYJ38i2QAzXEjDPdOmyYbqL62kJ06OnIyq9fCcvvGuKJ9WiJMnezdX8JlXEQXk
HHcP","bundle_identifier":"com.example.chatconnectycubesdk"}}

This log I got when subscription method called.

SUBSCRIPTION SUCCESS ====> [{notification_channel: gcm, push_token: null, device: {udid: ad156f91103bd48a, platform: android}}]

Code run as success but push_token get null.

  • Also one parameter got null from sendNotification() method and its log is
CUBE EVENT -----> [{notification_type: null, environment: development, message: {message: cfrthhu, custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_
parameter2: custom parameter value 2}, event_type: one_shot}]

Looks like you have the same error as before.

Yes, but in dashboard when I clicked on Push Notification -> Queue tab, notification status, it displays 2 Delivered, 2 Failed and above log.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Try to remove all subscriptions in the Connectycube dashboard and do the same again (reinstall the app (delete completely and install it again), subscribe, and send push notification). And see logs from callbacks for receiving push notifications on your device, I mean them:

connector.configure(
    onLaunch: onLaunch,
    onMessage: onMessage,
    onResume: onResume,
    onBackgroundMessage: onBackgroundMessage);

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Try to remove all subscriptions in the Connectycube dashboard and do the same again (reinstall the app (delete completely and install it again), subscribe, and send push notification). And see logs from in callbacks for receiving push notifications on your device, I mean them:

connector.configure(
    onLaunch: onLaunch,
    onMessage: onMessage,
    onResume: onResume,
    onBackgroundMessage: onBackgroundMessage);

@TatankaConCube

I did same step as you suggest, now I get title and body parameter null in onMessage() method.

This is notification log from dashboard. but still I didn't get notification and any changes in firebase console cloud messaging.

{
  "notification": {
    "id": 6905941,
    "badge": null,
    "device_token": null,
    "sound": "default",
    "alert": null,
    "data": {
      "message": "hii",
      "custom_parameter1": "FLUTTER_NOTIFICATION_CLICK",
      "custom_parameter2": "custom parameter value 2",
      "collapse_key": "event3374654"
    },
    "expiry": 86400,
    "delivered": true,
    "delivered_at": "2020-10-26T11:31:03+00:00",
    "failed": null,
    "failed_at": null,
    "fail_after": "2020-10-26T12:31:03+00:00",
    "retries": 0,
    "error_code": null,
    "error_description": null,
    "deliver_after": null,
    "alert_is_json": null,
    "app_id": 1283,
    "collapse_key": null,
    "delay_while_idle": false,
    "registration_ids": [
      "exid1TofSUis39TSygwM3v:APA91bF5r8sYKWcGfMPDrL5UoqYPcQ0A8e_yz_ZEIIV6OubKb8PWG_b1z_kX1sbn96lwNYOQ5-1COx6xKcBofCIexhUOJvpihP4zUnRKCfsfuWv9Bx9htEreHHTIZreNRCcW6ab6QEg0",
      "dSaTJ6IFS22N1EcVXO68NA:APA91bFLgSQEc2ezPtRSfBSEc3M_PUnkzrJYuh2dMo3PY-wRBWNaLVYEkYABCXnBHWHmI6qOehEWGkbbT8BBW_9BmsITQBlB_dlX_397r7xmPc8U0T3avxZhCN8HyQ770EstdtwR41Lt"
    ],
    "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": 3374654,
    "event_date": "2020-10-26T11:31:02+00:00"
  },
  "log": [
    {
      "device_token": null,
      "delivered_at": "2020-10-26T11:31:03+00:00",
      "failed_at": null,
      "error_code": null,
      "error_description": null
    }
  ]
}

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

I did same step as you suggest, now I get title and body parameter null in onMessage() method.

does it mean you receive a push notification on the device?

FYI, ConnectyCube server sends push notification with type 'data' not 'notification' it means you have search your data in parameter 'data', like in my draft code

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

does it mean you receive a push notification on the device?

@TatankaConCube

No, I don't receive notification on device but only got above log. Also there is nothing changes in firebase console.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

what means it?

now I get title and body parameter null in onMessage() method

In the log I can't see any errors, it means the Connectycube server successfully sent a push notification to FCM server. Please add logs to all callbacks and try to send push notification again.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024
"delivered": true,
"delivered_at": "2020-10-26T11:31:03+00:00",

it means push notification successfully delivered to FCM server

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Dear @TatankaConCube

For Firebase connection with connectycube_sdk, I have confusions are that

  • Should I have to enable any authentication sign-in option filed like email/password or phone in firebase console?

  • While using firebase_messaging packages to configure project, I have to define this two steps in my project or not?

5. Define a TOP-LEVEL or STATIC function to handle background messages

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    // Handle data message
    final dynamic data = message['data'];
  }

  if (message.containsKey('notification')) {
    // Handle notification message
    final dynamic notification = message['notification'];
  }

  // Or do other work.
}

Note: the protocol of data and notification are in line with the fields defined by a RemoteMessage.

6. Set onBackgroundMessage handler when calling configure

_firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        _showItemDialog(message);
      },
      onBackgroundMessage: myBackgroundMessageHandler,
      onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
        _navigateToItemDetail(message);
      },
      onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
        _navigateToItemDetail(message);
      },
    );

Note: configure should be called early in the lifecycle of your application so that it can be ready to receive messages as early as possible. See the example app for a demonstration.

Because this two method is same as connectycube_sdk methods. That's why I have this confusion?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Dear @TatankaConCube

For Firebase connection with connectycube_sdk, I have confusions are that

  • Should I have to enable any authentication sign-in option filed like email/password or phone in firebase console?
  • While using firebase_messaging packages to configure project, I have to define this two steps in my project or not?

5. Define a TOP-LEVEL or STATIC function to handle background messages

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    // Handle data message
    final dynamic data = message['data'];
  }

  if (message.containsKey('notification')) {
    // Handle notification message
    final dynamic notification = message['notification'];
  }

  // Or do other work.
}

Note: the protocol of data and notification are in line with the fields defined by a RemoteMessage.

6. Set onBackgroundMessage handler when calling configure

_firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        _showItemDialog(message);
      },
      onBackgroundMessage: myBackgroundMessageHandler,
      onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
        _navigateToItemDetail(message);
      },
      onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
        _navigateToItemDetail(message);
      },
    );

Note: configure should be called early in the lifecycle of your application so that it can be ready to receive messages as early as possible. See the example app for a demonstration.

Because this two method is same as connectycube_sdk methods. That's why I have this confusion?

@TatankaConCube

Please give me answer asap for my confusion.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

From the Firebase console you need:

  • enable Cloud messaging;
  • get Server token for Connectycube admin panel;
  • download and add to project google-services.json;
    These three points required from Firebase for working with FCM;

I have to define this two steps in my project or not?

yes, you have to create this static method and set it as the listener for the onBackgroundMessage callback.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

you have to create this static method and set it as the listener for the onBackgroundMessage callback.

Please help me how and where I have to change in code snippet. I mean in init() method I have to initialize any function?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

you can initialize plugin in method void initState() of your widget where you have logged in user. In this place, you can set listeners for events. The main thing - you have to do this immediately when you got logged in user.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

How can I get title and body parameter in onMessage() method while sending push_notification which I get null.

onMessage: {notification: {title: null, body: null}, data: {custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_parameter2: custom parameter value 2, message: greyj}}

Please give me suggestion asap.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

How can I get title and body parameter in onMessage() method while sending push_notification which I get null.

onMessage: {notification: {title: null, body: null}, data: {custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_parameter2: custom parameter value 2, message: greyj}}

Please give me suggestion asap.

@TatankaConCube

Please give solution of above question. Please reply!!

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

As I said before, the Connectycube server sends push notifications with type 'data', so you can add all required information to 'parameters' during the event creation. You can add all the needed data to this parameter.

One question - did I right understand, now you can receive push notifications on the device?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

As I said before, the Connectycube server sends push notifications with type 'data', so you can add all required information to 'parameters' during the event creation. You can add all the needed data to this parameter.

@TatankaConCube

  • This data I use for creating event. In this I mention all of the data which required as per documentation. Please check below code and if made mistake then please suggest me.
void sendPushNotification() {
    CreateEventParams params = CreateEventParams();
    params.parameters = {
      'message': '${textEditingController.text}',
      'custom_parameter1': 'custom parameter value 1',
      'custom_parameter2': "custom parameter value 2",
      'ios_voip': 1
    };
    params.notificationType = '${NotificationType.PUSH}';
    params.environment = CubeEnvironment.DEVELOPMENT;
    params.usersIds = _cubeDialog.occupantsIds;

    createEvent(params.getEventForRequest()).then((cubeEvent) {
      print('CUBE EVENT -----> $cubeEvent');
    }).catchError((error) {
      print('CUBE EVENT ERROR -----> $error');
    });
  }

One question - did I right understand, now you can receive push notifications on the device?

I can receive notification, if I get onMessage() method in 'data' parameter rather than 'notification'. Sorry, still I did not receive notification on device. But It successfully generated from connectycube dashboard.

onMessage: {notification: {title: null, body: null}, data: {custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_parameter2: custom parameter value 2, message: greyj}}

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

As I said before, the Connectycube server sends push notifications with type 'data', so you can add all required information to 'parameters' during the event creation. You can add all the needed data to this parameter.

@TatankaConCube
In above code snippet where I have to pass type 'data' as you said? Please suggest me.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

it can be like:

params.parameters = {
      'message': '${textEditingController.text}',
      'title': someTitle,
      'body': someBody,
// all needed parameters here 
      'ios_voip': 1
    };

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

it can be like:

params.parameters = {
      'message': '${textEditingController.text}',
      'title': someTitle,
      'body': someBody,
// all needed parameters here 
      'ios_voip': 1
    };

@TatankaConCube

I did exact same as you suggest but still I face that title and parameter null in onMessage() method. What should I do now?

params.parameters = {
'message': '${textEditingController.text}',
'title': 'Chat Notification',
'body': "chat body",
'notification_type': 'push',
'push_type': 'gcm',
'environment': 'development',
'ios_voip': 1,
'usersIds' = ${_cubeDialog.occupantsIds}
};

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

in the 'data' field? are you sure?
please provide log, like you did before. I mean it:

onMessage: {notification: {title: null, body: null}, data: {custom_parameter1: FLUTTER_NOTIFICATION_CLICK, custom_parameter2: custom parameter value 2, message: greyj}}

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

in the 'data' field? are you sure?

Yes.

please provide log, like you did before. I mean it:

onMessage, message: {notification: {title: null, body: null}, data: {notification_type: push, push_type: gcm, environment: development, body: c
hat body, title: Chat Notification, message: gfghgg}}

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

what about it:

data: {notification_type: push, push_type: gcm, environment: development, body: chat body, title: Chat Notification, message: gfghgg}

why you say

title and parameter null in onMessage()

I'm confused...

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

what about it:

data: {notification_type: push, push_type: gcm, environment: development, body: chat body, title: Chat Notification, message: gfghgg}

why you say

title and parameter null in onMessage()

I'm confused...

sorry for this.
but still I didn't receive notification.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

do you mean notification in the Android notifications center? For the Android platform, you should do it by yourself, please read our documentation (at the end of the section). For iOS, it is a system feature and here you can manage only actions, which happen by clicking on the notification.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@shivanijha002

Notification: title and body should not be null. How can I set these values?

For the Android platform, you have to set them to the parameters map, for iOS you can use some additional parameter from our API. Note: ConnectyCube server always sends GCM with 'data' type, not 'notification'.

Also, I do not get any notification on device. Though message is getting captured in debug console.

For Android, it is expected behavior. You have to do it yourself. For example, you can use flutter_local_notifications plugin for it.
For iOS, it is a system feature and the system does it instead of you.

Thank you for the details. It might be useful if you can add it in your documentation. I wasted 2 days trying out different things and hoping it will work without anything external.
flutter_local_notifications has worked for me on Android.

Hello @shivanijha002

I face same issue as you mentioned above. Please suggest me how can I use flutter_local_notifications with firebase_messaging for Android device notification. Please suggest me asap.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

@Significantinfotech2020 in your callback onMessage you have all the needed data, please read documentation how to configure notification with this data and how to show it.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Hello @TatankaConCube,

I share my chat_dialog_screen.dart file. In this file I implemented flutter_local_notifications with firebase_messaging, but still I can't get any notification on receiver device. In this code I got notification on sender device with only notification title.
So, please check my code and let me know where I made mistake? What changes I have to do in this code?

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

There are few plugins for listening push notifications and a lot of code is commented. Do you receive a push event in your callbacks?
We are going to plan to add a push notification feature for the Chat sample in the next iteration.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

@Significantinfotech2020 today I pushed draft code for enabling push notifications in the Chat sample. The main logic for subscription, listening push notifications and showing local notifications placed in push_notifications_manager.dart

At current moment works (tested on iOS and Android):

  • subscription on push notifications;
  • receiving push notifications in the background (or killed) and foreground;
  • displaying notifications in Notification Center;
  • unsubscription from push notifications after logout from the app;

Note: it is just a draft and not all features implemented yet, for example, navigation to concrete chat by notification click, etc.

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@Significantinfotech2020 today I pushed draft code for enabling push notifications in the Chat sample. The main logic for subscription, listening push notifications and showing local notifications placed in push_notifications_manager.dart

At current moment works (tested on iOS and Android):

  • subscription on push notifications;
  • receiving push notifications in the background (or killed) and foreground;
  • displaying notifications in Notification Center;
  • unsubscription from push notifications after logout from the app;

Note: it is just a draft and not all features implemented yet, for example, navigation to concrete chat by notification click, etc.

@TatankaConCube I checked this code. It's working as you describe. Thanks πŸ‘

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Hello @TatankaConCube
In your code sometimes I got notification but sometimes not. I had updated code as per latest documentation. There was not any error in the terminal.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

In which way do you send push notification? From admin panel?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube

In which way do you send push notification?

I am sending notification as per your updated code.

From admin panel?

No.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Did these notifications present in the queue in the Admin panel?

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

Did these notifications present in the queue in the Admin panel?

when I receive notification on device that entries were in admin panel, but when I not get notification, that entry was not in queue.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

it means you have a problem not with receiving but with sending notifications, investigate this part of your code

from connectycube-flutter-samples.

Significantinfotech2020 avatar Significantinfotech2020 commented on July 23, 2024

@TatankaConCube In below method 6543 is what? Is this application ID or Account ID or anything else?

FlutterLocalNotificationsPlugin().show(
    6543, 
    "Chat sample",
    data['message'].toString(),
    platformChannelSpecifics,
    payload: 'item x',
  );

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

There is code not from our SDK, it is a code of flutter_local_notifications plugin. There is the description for this code example. In my example, 6543 is just a random notification id. Notification id - for the Android system it is the unique id of your notification, by this id you can cancel notification, update it, etc.

from connectycube-flutter-samples.

TatankaConCube avatar TatankaConCube commented on July 23, 2024

Implemented in the latest version. Closing...

from connectycube-flutter-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.