[AC-5484] Fail to sent ios notification.
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2018-02-05T21:07:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | lau.yikonn |
Assignee | Shak Hossain |
Created | 2018-01-03T06:35:18.000+0000 |
Updated | 2018-02-05T21:07:44.000+0000 |
Description
when i try to send an IOS notification, it show this error status.
Exception Type: APNS; Error Code: 2010; Error Message: Socket is closed; Catched Exception: Socket Closed
Attachments
Hello [~lau.yikonn], Thanks for sharing with us. Can you please share your sample code and environment details here so that we can reproduce the issue on our end? Best
var Cloud = require('ti.cloud'); var app_status; if(Ti.Platform.osname == "android"){ var CloudPush = require('ti.cloudpush'); CloudPush.addEventListener('callback', function (evt) { var payload = JSON.parse(evt.payload); Ti.App.Payload = payload; // if trayClickLaunchedApp or trayClickFocusedApp set redirect as true console.log("callback push"); }); CloudPush.addEventListener('trayClickLaunchedApp', function (evt) { var payload = JSON.parse(evt.payload); receivePush(payload); console.log('Tray Click Launched App (app was not running)'); app_status = "not_running"; //getNotificationNumber(Ti.App.Payload); }); CloudPush.addEventListener('trayClickFocusedApp', function (evt) { var payload = JSON.parse(evt.payload); console.log('Tray Click Focused App (app was already running)'); receivePush(payload); app_status = "running"; }); } function getNotificationNumber(payload){ console.log(payload); } // Process incoming push notifications function receivePush(e) { console.log(e); console.log('receive push'); if(OS_IOS){ if(e.data.target == "chatroom"){ } }else{ if(e.target == "chatroom"){ } } //Action after receiving push message return false; } function deviceTokenSuccess(ex) { console.log("deviceTokenSuccess"); deviceToken = ex.deviceToken; Cloud.PushNotifications.subscribeToken({ channel: 'general', type:Ti.Platform.name == 'android' ? 'android' : 'ios', device_token: deviceToken }, function (sub) { console.log(sub); if (sub.success) { /** User device token**/ console.log(deviceToken+" push"); Ti.App.Properties.setString('deviceToken', deviceToken); } }); } function deviceTokenError(e) { alert('Failed to register for push notifications! ' + e.error); } function registerPush(){ if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) { // Wait for user settings to be registered before registering for push notifications Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() { // Remove event listener once registered for push notifications Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush); Ti.Network.registerForPushNotifications({ success: deviceTokenSuccess, error: deviceTokenError, callback: receivePush }); }); // Register notification types to use Ti.App.iOS.registerUserNotificationSettings({ types: [ Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE ] }); }else if(Ti.Platform.osname == "android"){ CloudPush.retrieveDeviceToken({ success: deviceTokenSuccess, error: deviceTokenError }); }else{ Titanium.Network.registerForPushNotifications({ types: [ Titanium.Network.NOTIFICATION_TYPE_BADGE, Titanium.Network.NOTIFICATION_TYPE_ALERT, Titanium.Network.NOTIFICATION_TYPE_SOUND ], success:deviceTokenSuccess, error:deviceTokenError, callback:receivePush }); } } registerPush();
im using the axway platform to send to all user.
[~lau.yikonn] Can you change this line of code? - if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) And use this - if ((Ti.Platform.osname === 'iphone' || Ti.Platform.osname === 'ipad' || Ti.Platform.osname === 'ipod') && parseInt(Ti.Platform.version.split(".")[0]) >= 8) Finally, delete the App from the device then reinstall it. Make sure the device has been subscribed successfully on the dashboard. Then send the push again. Hope this helps.
it is not related with the code. i ask my friend to setup ios push notification at his appcelerator platform account. and then everything work fine. i think is something wrong with the configuration at platform there.
Hello, can you try configuring a new sample app and try sending push in there? Thanks.
Hello [~lau.yikonn], Just passing a followup here.Are you able to get that sorted out? Please let us know if you need more help with this issue. Regards Axway Appcelerator Support