roblav96 / nativescript-onesignal

A Nativescript plugin that wraps the iOS and Android OneSignal Push Notifications SDK.
https://documentation.onesignal.com/docs/getting-started
Other
24 stars 42 forks source link

Help Implement Notification opened/received #34

Open webmeemba opened 6 years ago

webmeemba commented 6 years ago

Me code is:

TnsOneSignal.startInit(androidApp.context).init();

I need :
TnsOneSignal.handleNotificationOpened((jsonData) => { console.log('didOpenRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
})

not found

OPADA-Eng commented 6 years ago

ios:

private applicationDidFinishLaunchingWithOptions(app, launchOptions): boolean {
      try {
        TnsOneSignal.initWithLaunchOptionsAppIdHandleNotificationAction(
          launchOptions,
          'APP_ID',
          function actionCallback(result) {
            Helpers.handleOpenNotification(JSON.parse(result.stringify()).notification.payload.additionalData)
          }
        );
        TnsOneSignal.inFocusDisplayType = OSNotificationDisplayType.Notification
      } catch (error) {
        console.error('error', error)
      }
      return true
    }

android:

TnsOneSignal.startInit(app.android.context).setNotificationOpenedHandler(new com.onesignal.OneSignal.NotificationOpenedHandler(<com.onesignal.OneSignal.NotificationOpenedHandler>{
        notificationOpened: function (result: com.onesignal.OSNotificationOpenResult) {
          console.log("------------------------notificationOpened------------------------")
          // console.dir(JSON.parse(result.notification.payload.additionalData));
        },
      })).init();
delanick commented 6 years ago

@webmeemba did this work for you?

@OPADA-Eng can you perhaps please post the JS version of your solution(s)? I struggle with TS. :)

OPADA-Eng commented 6 years ago

Android:

app.on(app.launchEvent, function (args) {
        imageCache.initialize();
        try {
            // TnsOneSignal.startInit(app.android.context).setNotificationOpenedHandler(new TnsOneSignal.NotificationOpenedHandler(<TnsOneSignal.NotificationOpenedHandler>{
            TnsOneSignal.startInit(app.android.context).setNotificationOpenedHandler(new TnsOneSignal.NotificationOpenedHandler({
                // notificationOpened: function (result: com.onesignal.OSNotificationOpenResult) {
                notificationOpened: function (result) {
                    console.log("------------------------notificationOpened------------------------");
                    // console.dir(JSON.parse(result.notification.payload.additionalData));
                },
            })).init();
            TnsOneSignal.setInFocusDisplaying(TnsOneSignal.OSInFocusDisplayOption.Notification);
        }
        catch (error) {
            console.error('error', error);
        }
    });

IOS:

 CustomAppDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {
        try {
            TnsOneSignal.initWithLaunchOptionsAppIdHandleNotificationAction(launchOptions, 'APP_ID', function actionCallback(result) {
                conaole.log(JSON.parse(result.stringify()).notification.payload.additionalData);
            });
            TnsOneSignal.inFocusDisplayType = OSNotificationDisplayType.Notification;
        }
        catch (error) {
            console.error('error', error);
        }
        return true;
    };
delanick commented 6 years ago

@OPADA-Eng Thanks so much - going to give it a try as soon as my current app's iOS build completes and I finish submitting to the AppStore :)

delanick commented 5 years ago

@OPADA-Eng Could you perhaps talk me through the JS code that you wrote? Busy trying to implement it but want to understand what I'm seeing.

OPADA-Eng commented 5 years ago

Ok no problem, How do you want to talk?

On Tue, Dec 4, 2018, 1:32 PM delanick <notifications@github.com wrote:

@OPADA-Eng https://github.com/OPADA-Eng Could you perhaps talk me through the JS code that you wrote? Busy trying to implement it but want to understand what I'm seeing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/roblav96/nativescript-onesignal/issues/34#issuecomment-444068830, or mute the thread https://github.com/notifications/unsubscribe-auth/ACGJaFudEbOH6gnkGYnJOsofqpWrPor1ks5u1l02gaJpZM4T_0e3 .

delanick commented 5 years ago

@OPADA-Eng I'm easy, whatever works for you. We could do a quick Skype call if that suits you. What time zone are you in? I can do anywhere after 8pm South African time.

OPADA-Eng commented 5 years ago

Ok, we are at the same time zone.it's ok at 9:00 pm today. this is my skype name: opada-eng1

delanick commented 5 years ago

@OPADA-Eng Apologies bud, I was away yesterday. Can we do today at 9pm? My skype name is delannick. Apoloigies again for missing your message yesterday.

delanick commented 5 years ago

@OPADA-Eng Oops, sorry, delanick with one N :)

jannomeister commented 5 years ago

also having a hard time implement push notification using this plugin :(