问题
I'm trying to implement the push functionality in Sinch.
I've set up my since client as such:
[_client setSupportMessaging:YES];
[_client setSupportPushNotifications:YES];
_client.delegate = self;
[_client start];
[_client startListeningOnActiveConnection];
Then on
- (void)clientDidStart:(id<SINClient>)client {
client.messageClient.delegate = self;
}
And in AppDelegate.h
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// get previously initiated Sinch client
id<SINClient> client = [SinchClient sharedClient].client;
[client registerPushNotificationData:deviceToken];
}
The other delegate methods work fine (messageSent, messageDelivered, etc), however, I can't seem to invoke
(void)message:(id<SINMessage>)message shouldSendPushNotifications:(NSArray *)pushPairs
for testing, I've setup two phones each running a SinchClient, and force quit the app on the one of the phones (assuming that should trigger the offline state) - still no dice though. I'm watching a breakpoint, but the delegate doesn't seem to be firing.
Any thoughts?
Thanks, Charlie
回答1:
Make sure that both phones have registered push data (won't work on a simulator for example). Otherwise, putting one of these devices in flight mode and try to send a message to that device should suffice to get the shouldSendPushNotification
callback (make sure you are signed in as different user on the two devices).
If you don't receive the messageSent
callback you won't receive the shouldSendPushNotification
callback. Likewise, if you receive the messageDelivered
event, you won't get the shouldSendPushNotification
.
来源:https://stackoverflow.com/questions/23962771/sinch-message-shouldsendpushnotification-not-being-called