Skip to content

Didn't Receive Push Notification #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
codxse opened this issue Feb 8, 2020 · 9 comments
Closed

Didn't Receive Push Notification #2

codxse opened this issue Feb 8, 2020 · 9 comments
Labels
question Further information is requested

Comments

@codxse
Copy link

codxse commented Feb 8, 2020

Hi all,

Thank you for making such a plugin. Helping me a lot. I have question about push notification integration, especially for iOS platform. Well, I managed to integrate and push the FCMtoken to CleverTap dashboard. But I have an issue with receiving the notification, there was no notification at all, although it said "successfully sent".

I am following readme guide to integrate using CleverTap.autoIntegrate().

import UIKit
import Flutter
import flutter_downloader
import CleverTapSDK
import UserNotifications

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      if #available(iOS 10.0, *) {
        UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
      }
    CleverTap.autoIntegrate()
    GeneratedPluginRegistrant.register(with: self)
    FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

private func registerPlugins(registry: FlutterPluginRegistry) {
    //
    // Integration note:
    //
    // In Flutter, in order to work in background isolate, plugins need to register with
    // a special instance of `FlutterEngine` that serves for background execution only.
    // Hence, all (and only) plugins that require background execution feature need to
    // call `register` in this function.
    //
    // The default `GeneratedPluginRegistrant` will call `register` of all plugins integrated
    // in your application. Hence, if you are using `FlutterDownloaderPlugin` along with other
    // plugins that need UI manipulation, you should register `FlutterDownloaderPlugin` and any
    // 'background' plugins explicitly like this:
    //
    // FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "vn.hunghd.flutter_downloader"))
    //
    GeneratedPluginRegistrant.register(with: registry)
}

And I am initi the CleverTap on dart main function

...

    super.initState();
    _initPlatformState();
    cp.ClevertapPlugin.getInstance().activateCleverTapFlutterPluginHandlers();
    cp.CleverTapPlugin.setDebugLevel(3);
    cp.CleverTapPlugin.createNotificationChannelGroup("default-group", "Default Notification Group");
    cp.CleverTapPlugin.createNotificationChannel("default-channel", "Default Notification Channel", "YourChannelDescription", 3, true);
    cp.CleverTapPlugin.initializeInbox();

...

  void activateCleverTapFlutterPluginHandlers(){
    _clevertapPlugin = new CleverTapPlugin();
    _clevertapPlugin.setCleverTapInAppNotificationDismissedHandler(inAppNotificationDismissed);
    _clevertapPlugin.setCleverTapProfileDidInitializeHandler(profileDidInitialize);
    _clevertapPlugin.setCleverTapProfileSyncHandler(profileDidUpdate);
    _clevertapPlugin.setCleverTapInboxDidInitializeHandler(inboxDidInitialize);
    _clevertapPlugin.setCleverTapInboxMessagesDidUpdateHandler(inboxMessagesDidUpdate);
  }

...

Is there any configuration I missed?

Thank you

@Aditi3
Copy link
Contributor

Aditi3 commented Feb 9, 2020

Hi @codxse

It seems you are sending FCM Token to the CleverTap. FCM token is not supported on the iOS platform.
Could you send an APNS token and verify it again?

Also, you can implement our method to register for Push on iOS.

Code snippet for the same:

CleverTapPlugin.registerForPush();

Helping link to our Example Application: https://github.com/CleverTap/clevertap-flutter/blob/master/example/lib/main.dart#L28

Thank you :)

@codxse
Copy link
Author

codxse commented Feb 10, 2020

Thanks @Aditi3, I appreciate your answer.

Yes, It turn out that I have to push APNS token first. And I successfully send the notification message to the phone. :)


Here the code with registerForPush();

    super.initState();
    _initPlatformState();
    cp.ClevertapPlugin.getInstance().activateCleverTapFlutterPluginHandlers();
    cp.CleverTapPlugin.setDebugLevel(3);
    cp.CleverTapPlugin.createNotificationChannelGroup("default-group", "Default Notification Group");
    cp.CleverTapPlugin.createNotificationChannel("default-channel", "Default Notification Channel", "YourChannelDescription", 3, true);
    cp.CleverTapPlugin.initializeInbox();
    log.i('registerFOrPush');
    cp.CleverTapPlugin.registerForPush();
    Future<String> initialUrl = cp.CleverTapPlugin.getInitialUrl();
    initialUrl.then((String url) { log.i('CleverTap initialUrl: $initialUrl'); });

Question again. But, how do I read custom key-value? is there any method or handler to read that?

@Aditi3
Copy link
Contributor

Aditi3 commented Feb 11, 2020

Hi @codxse

Looks like you want to handle the push notifications payload and process the user's response to a notification.

Here is the link where you can find the answer to handle the notifications: 
https://stackoverflow.com/questions/55350391/cannot-read-payload-of-push-notification-sent-from-clevertap-dashboard/55361276#55361276

The link point to the React-Native SDK but the same solution can be implemented and should be functional in the Flutter SDK.

Hope this helps.

@thesmalleyes
Copy link

Hi all,

Thank you for making such a plugin. Helping me a lot. I have question about push notification integration, especially for iOS platform. Well, I managed to integrate and push the FCMtoken to CleverTap dashboard. But I have an issue with receiving the notification, there was no notification at all, although it said "successfully sent".

I am following readme guide to integrate using CleverTap.autoIntegrate().

import UIKit
import Flutter
import flutter_downloader
import CleverTapSDK
import UserNotifications

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      if #available(iOS 10.0, *) {
        UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
      }
    CleverTap.autoIntegrate()
    GeneratedPluginRegistrant.register(with: self)
    FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

private func registerPlugins(registry: FlutterPluginRegistry) {
    //
    // Integration note:
    //
    // In Flutter, in order to work in background isolate, plugins need to register with
    // a special instance of `FlutterEngine` that serves for background execution only.
    // Hence, all (and only) plugins that require background execution feature need to
    // call `register` in this function.
    //
    // The default `GeneratedPluginRegistrant` will call `register` of all plugins integrated
    // in your application. Hence, if you are using `FlutterDownloaderPlugin` along with other
    // plugins that need UI manipulation, you should register `FlutterDownloaderPlugin` and any
    // 'background' plugins explicitly like this:
    //
    // FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "vn.hunghd.flutter_downloader"))
    //
    GeneratedPluginRegistrant.register(with: registry)
}

And I am initi the CleverTap on dart main function

...

    super.initState();
    _initPlatformState();
    cp.ClevertapPlugin.getInstance().activateCleverTapFlutterPluginHandlers();
    cp.CleverTapPlugin.setDebugLevel(3);
    cp.CleverTapPlugin.createNotificationChannelGroup("default-group", "Default Notification Group");
    cp.CleverTapPlugin.createNotificationChannel("default-channel", "Default Notification Channel", "YourChannelDescription", 3, true);
    cp.CleverTapPlugin.initializeInbox();

...

  void activateCleverTapFlutterPluginHandlers(){
    _clevertapPlugin = new CleverTapPlugin();
    _clevertapPlugin.setCleverTapInAppNotificationDismissedHandler(inAppNotificationDismissed);
    _clevertapPlugin.setCleverTapProfileDidInitializeHandler(profileDidInitialize);
    _clevertapPlugin.setCleverTapProfileSyncHandler(profileDidUpdate);
    _clevertapPlugin.setCleverTapInboxDidInitializeHandler(inboxDidInitialize);
    _clevertapPlugin.setCleverTapInboxMessagesDidUpdateHandler(inboxMessagesDidUpdate);
  }

...

Is there any configuration I missed?

Thank you

Can you share your example code for using clevertap. because i can't see data in my dashboart.
and i go t a meesage "Somebody has invoked me to send the queue to CleverTap servers" ?

@darshanclevertap
Copy link
Contributor

@bayuramadeza The repo contains an example project. Please check out the main.dart file

@darshanclevertap
Copy link
Contributor

@codxse Is your issue resolved or is there something we can help you with? Please let us know

@thesmalleyes
Copy link

My issue has been closed, after i added region in manifest. Thanks

@Aditi3
Copy link
Contributor

Aditi3 commented Feb 26, 2020

Hi @bayuramadeza

Great, glad to know it worked for you.

@Aditi3
Copy link
Contributor

Aditi3 commented Feb 26, 2020

Hi @codxse

I am going to close this issue here. If you need further help please feel free to email support at [email protected].

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants