Skip to content
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
This repository was archived by the owner on Feb 7, 2019. It is now read-only.

ios message received on multiple times when the app is in foreground #194

Open

Description

@priyangamani

I registered the push id only once but the token will generate twice in ios device.

Activity

  1. NickIliev commented on Feb 1, 2018

    @NickIliev

    @priyangamani please provide a sample project to reproduce and investigate the issue.

  2. priyangamani commented on Feb 2, 2018

    @priyangamani
    Author

    //LoginPage.js
    var pushPlugin = require("nativescript-push-notifications");
    var http = require("http");

    LoginPage.prototype.pageLoaded = function (args) {
    var settings = {
    senderID:'98765431234',
    notificationCallbackAndroid: function (message, data) {
    var payload = JSON.parse(data);
    switch (payload.action) {
    case "NEWS":
    alert(payload.id)
    break;
    case "MESSAGE":
    alert(payload.id)
    break;
    default:
    alert("message");
    }
    notificationCallbackIOS: function (data) {
    alert(JSON.stringify(data));
    },
    badge: true, // Enable setting badge through Push Notification
    sound: true, // Enable playing a sound
    alert: true, // Enable creating a alert
    };
    pushPlugin.register(settings,
    // Success callback
    function (token) {
    http.request({url:"http://192.168.10.189:50780/updatePush"+token,
    method: "POST",
    headers: { "Content-Type": "application/json"}
    })
    var pushSettings = settings;
    if (token != '') {
    if (pushPlugin.onMessageReceived) {
    pushPlugin.onMessageReceived(settings.notificationCallbackAndroid);
    }
    }
    },
    function (error) {
    console.log("Error");
    }
    );
    }
    }

    Package.json
    "nativescript-push-notifications": "^1.0.5",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions