Ramsha Omer
Ramsha Omer

Reputation: 1052

Pushwoosh implementation in ionic 2 application

I have implemented pushwoosh in my application using pushswoosh plugin and it is working perfect. But as i also have a mySQL server and for that i want to save my token after registering my device with pushwoosh. I want to save the token arrived from pushwoosh in local sqlite first. For that i am using pushwoosh build in method.

  pushwoosh.getPushToken(
        function(token) {
            console.warn('push token: ' + token);
        }
    );

I want this token out from this above mention javascript function. Can any java script expert give me any advice or any other solution.

I have already tried the following code and is not working.

        var _token;     
        pushwoosh.getPushToken(
                function(token) {
                _token = token;
                    console.warn('push token: ' + token);
                }
            );
    console.log("Token: "+_token);
//output: Token: undefined

Upvotes: 0

Views: 47

Answers (1)

Ramsha Omer
Ramsha Omer

Reputation: 1052

Here is the solution i should use the function like this in ionic 2

pushwoosh.getPushToken(
        (token) => {
            console.warn('push token: ' + token);
        }
    );

Hope this will help others as well.

Upvotes: 0

Related Questions