我正在尝试使用 Worklight 推送通知来发送推送 iOS+Android 应用程序。
我在我的适配器中创建了 submitNotification 函数,当我调用它时,它说推送已成功发送,但实际上我的设备中没有收到推送。
当我看到日志时,我可以阅读:
Couldn't connect to APNS server
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
java.net.Socket.connect(Socket.java:529)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:371)
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:133)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)
和
Couldn't send message com.notnoop.apns.EnhancedApnsNotification@96eee2c0 com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:146)
com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
java.util.concurrent.FutureTask.run(FutureTask.java:138)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)
然后
Failed to send message com.notnoop.apns.EnhancedApnsNotification@96eee2c0... trying again
我的 submitNotification 功能:
function submitNotification(userId, notificationText) {
var userSubscription = WL.Server.getUserNotificationSubscription(
'myAdapter.MyPushEventSource', userId);
if (userSubscription == null) {
return {
result : "No subscription found for user :: " + userId
};
}
WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: "
+ notificationText);
WL.Server.notifyAllDevices(userSubscription, {
badge : 1,
activateButtonLabel : "Open",
alert : notificationText
});
return {
result : "Notification sent to user :: " + userId
};
}
我的代码有问题吗?或与我的网络?