Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

createLocalNotification is not defined in 6.3.0 #223

Closed rwillett closed 6 years ago

rwillett commented 7 years ago

Hi,

We're trying to use the createLocalNotification as described in the plugin docs at

https://rawgit.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin/master/Documentation/files/PushNotification-js.html#PushNotification.createLocalNotification

Our code is pretty simple

        for (var i = 0 ; i < notification.length ; i++)
        {
            pushNotification.createLocalNotification({
                msg: "Test" + i ,
                seconds: i * 20 ,
                userData: { id: i }
            } , function () {
                ConsoleLog("PushWoosh Local Notification success");
            } , function () {
                ConsoleLog("PushWoosh Local Notification failure");
            });
        }

It runs down an array of notifications we want to send and sends them every 20 secs. This is a simple test case for us.

We are getting an error under IOS 8 with 6.3.0 of

2016-11-02 12:21:10.136 Jambuster[3469:250820] ERROR: Method 'createLocalNotification:' not defined in Plugin 'PushNotification'
2016-11-02 12:21:10.136 Jambuster[3469:250820] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["PushNotification1180279827","PushNotification","createLocalNotification",[{"msg":"Test 0","seconds":0,"userData":{"id":0}}]]
2016-11-02 12:21:10.136 Jambuster[3469:250820] ERROR: Method 'createLocalNotification:' not defined in Plugin 'PushNotification'
2016-11-02 12:21:10.136 Jambuster[3469:250820] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["PushNotification1180279828","PushNotification","createLocalNotification",[{"msg":"Test 1","seconds":20,"userData":{"id":1}}]]
2016-11-02 12:21:10.136 Jambuster[3469:250820] ERROR: Method 'createLocalNotification:' not defined in Plugin 'PushNotification'
2016-11-02 12:21:10.137 Jambuster[3469:250820] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["PushNotification1180279829","PushNotification","createLocalNotification",[{"msg":"Test 2","seconds":40,"userData":{"id":2}}]]
2016-11-02 12:21:10.137 Jambuster[3469:250820] ERROR: Method 'createLocalNotification:' not defined in Plugin 'PushNotification'
2016-11-02 12:21:10.137 Jambuster[3469:250820] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["PushNotification1180279830","PushNotification","createLocalNotification",[{"msg":"Test 3","seconds":60,"userData":{"id":3}}]]

We checked plugins/pushwoosh-cordova-plugin/www/PushNotification.js and can see that createLocalNotification is declared. We also checked every other PushNotification.js and can see it in there.

We also tried

        for (var i = 0 ; i < notification.length ; i++)
        {
            pushNotification.createLocalNotification({
                msg: "Test " + i ,
                seconds: i * 20 ,
                userData: { id: i }
            });
    }

and that failed in the same way.

Have we missed something simple? We know that we have created and set pushNotification so its not that.

Thanks

Rob

rwillett commented 7 years ago

Has the documentation just been updated to remove createLocalNotification from IOS?

We thought it had Android AND IOS as supported, it now just says Android.

Rob

rwillett commented 7 years ago

Be good to get an answer here

viridanti commented 7 years ago

Hi,

Please note that the createLocalNotification method is supported on Android only, and there was no such method for iOS.

rwillett commented 6 years ago

Hi, I'm opening this again as the documentation on the website (https://docs.pushwoosh.com/docs/cordova-api-reference#section-createlocalnotification) now states that createLocalNotification works for both IOS and Android. We thought the docs had been updated to now include IOS for createLocalNotification in versions of the plugin.

Just wasted an hour rewriting some code to test this out as it would be great to have it, to find its NOT supported and the documentation is wrong yet again.

This is a problem if we can't trust the official documentation as to what is supported or not, this means we have to ask and waste your time and our own.

screen shot 2018-01-09 at 14 53 01

wfhm commented 6 years ago

Hi Rob,

Checking it right now.

rwillett commented 6 years ago

Thanks, would be good to get either the documents updated so we know they are correct.

wfhm commented 6 years ago

@rwillett to my knowledge, you have been contacted by our support team, and they provided you with an updated docs. Could you please confirm it?

Just in case, below is a correct way to call this method:

pushNotification.createLocalNotification({msg:"Your message here", seconds: 10, userData:[]});
rwillett commented 6 years ago

No docs I'm afraid. I don't want any to be honest, I want the website to be accurate.

So is this method available to IOS?

wfhm commented 6 years ago

@rwillett yes, the example above is how it should be called for iOS. Please let us know about results

rwillett commented 6 years ago

I've tested this using the following code and can confirm it works on IOS 10 with PushWoosh pushwoosh-cordova-plugin 7.2.3

function SendPushWooshLocalDummyNotification() {
        var debugSendPushWooshLocalDummyNotification = debugTrue;

        var notification = { seconds: 30 ,
                             userData: { type: "DisruptionNotification" , disruptionId: -1 } ,
                             msg: "[A102] Blackwall Tunnel Southern Approach (S/B) - The carriageway is blocked southbound. Collision between two cars. Carriageway blocked. Police on scene are removing vehicles. Expect long delays."
                           };

        if (debugSendPushWooshLocalDummyNotification)
            ConsoleLog("SendPushWooshLocalDummyNotification: " + JSON.stringify(notification , null , 2));

        pushNotification.createLocalNotification(notification , function () {
            if (debugSendPushWooshLocalDummyNotification)
                ConsoleLog("SendPushWooshLocalDummyNotification: schedule callback OK");
        } , function () {
            if (debugSendPushWooshLocalDummyNotification)
                ConsoleLog("SendPushWooshLocalDummyNotification: schedule callback failed");
        });
    }