techaffinity / freshchat-phonegap

Freshchat sdk for phonegap
7 stars 36 forks source link

Phone Gap Plugin push notification configurationnot working #36

Open koteshgit opened 5 years ago

koteshgit commented 5 years ago

Hi, I tried to set up push notifications by providing the Serial ID. But it is not working. I need some assistance to setup the push notifications for phonegap fc plugin.

Please arrange small call so that It will be useful for us.

Thanks & Regards Kotesh 7032675401

koteshgit commented 5 years ago

pushmessage

koteshgit commented 5 years ago

Please help me to configure the push notification configuration for ionic3 mobile app Kotesh 7032675401

techaffinity commented 5 years ago

Please try one of the below steps to see if it fixes the issue

Step 1: Remove Cordova plugin using the following command cordova plugin rm cordova-plugin-freshchat Then remove android platform. cordova platform rm android. Now add cordova plugin. cordova plugin add https://github.com/techaffinity/freshchat-phonegap.git Then add android platform. cordova platform add android

Step 2: The working code is given below, please refer for clarifications

  initialPluginPush() {
let push = (window as any).PushNotification.init({
  android: {
    senderID: "" //You add firebase senderId
  },
  ios: {
    alert: "true",
    badge: true,
    sound: 'false'
  },
  windows: {}
});

push.on('registration', (data) => {
  console.log(data.registrationId);
  (window as any).Freshchat.updatePushNotificationToken(data.registrationId);
});

push.on('notification', (data) => {
  (window as any).Freshchat.isFreshchatPushNotification(data, function (isFreshchatNotif) {
    console.log(isFreshchatNotif);
    if (isFreshchatNotif) {
      console.log("entered inside Freshchat for handle");
      (window as any).Freshchat.handlePushNotification(data);
    } else {
      console.log("entered else  for handle");
      alert(data);
    }
  });
});

push.on('error', (e) => {
  console.log(e.message);
});

}

Swatantramishra1 commented 5 years ago

image

Hi While adding a plugin, its creating gradle issue.

Swatantramishra1 commented 5 years ago

Will it work without adding cordova plugin add https://github.com/techaffinity/phonegap-plugin-push.git --variable SENDER_ID=20738924380 ?

Swatantramishra1 commented 5 years ago

@techaffinity any update ?

techaffinity commented 4 years ago

Hi Did you try adding the below plugin as mentioned in the docs https://github.com/dpa99c/cordova-android-support-gradle-release

Can you try and share us the response?