Sinch APN shouldSendPushNotifications never called - sinch

I can´t make Apple Push Notifications work in development mode. The shouldSendPushNotifications method is never called on the source device when the target device is in background mode. I have uploaded my APN development certificate in the Sinch Dashboard and instant messaging works if both devices are in foreground mode. I have a valid device token which I´m using for my own Push Messages. Here is my code:
sinCli = Sinch.clientWithApplicationKey("XXXX", applicationSecret: "XXXX", environmentHost: "sandbox.sinch.com", userId: sinchUserId)
sinCli.delegate = self
sinCli.setSupportMessaging(true)
if let deviceToken = defaults.dataForKey(Globals.KEY_APN_DEVICE_TOKEN)
{
sinCli.setSupportPushNotifications(true)
sinCli.registerPushNotificationDeviceToken(deviceToken, type: SINPushTypeRemote, apsEnvironment: SINAPSEnvironment.Development)
sinCli.setPushNotificationDisplayName("MyApp")
}
sinCli.start()
sinCli.startListeningOnActiveConnection()
sinCli.messageClient().delegate = self
did I forget something?

I think I need to see your swift wrapper, but it almost looks like you are setting up the client for push (not managed), and then registring the token for managed push.
When using managed push (when you upload to cert to us) shouldSendPush is never called, because Sinch takes care of the pushing, you should just get a push. What you do need is to have a push delegate https://www.sinch.com/tutorials/ios-managed-push/

Related

Unclear error message on sending a notification to iOS

I'm trying to send a notification via C# SDK. I'm sending notifications for iOS.
string payload = "{\"aps\" : { \"alert\" : \"Message received from Bob\" }}";
var outcome = hub.SendAppleNativeNotificationAsync(payload, new[] { "b6a5d9c3-4297-422f-9a8d-b7979c30a5f8" }).GetAwaiter().GetResult();
Registration works fine, I can retrieve registered users, but I receive errors on sending. The error message is
Contract mismatch between ServiceBus and the Push Notification System
I've looked into manage.windowsazure.com for monitoring and saw that there were errors of type “Bad channel error”.
I assume that I should try to change my region for NH and probably the problem will go away, but is there anything else I could look at to resolve this issue?
Forgot to mention that everything was working on the first day I started to work with push notifications and only after several days became broken without any changes.
you may have open port 2135 and also add APN certificate
I didn't figured out what does that error mean but at least found the root cause. It was Testflight that by some obscure reasons uses production gateways to send notifications and not sandbox, and my NH has been configured with sandbox certificate, that's why it didn't work.

iOS Google Play Service's push notifications is working at this time?

I'm building an iOS game using Google Play Game for turn-based multiplayer but cannot receive any notifications. I did research many days to find what is wrong but i can't find anything.
So is iOS push notification in Google Play game still working at this time? Do your games still receive push notifications normally? Please provide me some information.
Thank you!
It is still indicated in the documentation that invitation and turn notifications are currently supported on Android and iOS. Based from this tutorial, you need to register your app to receive push notifications.
In your appDelegate, add the following code to the callback for retrieving the push device token passed back from APNS. This device token is used for outbound push notifications, and your app must register it with the Google Play games services push service. Make sure to always register your device token through GPGManager to enable push notifications from Google Play games services. Even if the user has not signed in; the GPGmanager object will cache this token and save it until the user signs in.
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken
:(NSData *)deviceToken {
NSLog(#"Got deviceToken from APNS! %#", deviceToken);
[[GPGManager sharedInstance] registerDeviceToken:deviceToken
forEnvironment:GPGPushNotificationEnvironmentSandbox];
}
From this related thread:
If you are having issues you might want to make sure the token is being registered correctly with APNS in the AppController.m (by logging it).
Also, there are two certificates you can register on the Play console, one for sandbox and one for production. Make sure that certificate you are using is the one being configured. By default the AppController calls
gpg::RegisterDeviceToken(deviceToken, false); which indicates that this is the prod certificate configured on the console.
You can also check this related GitHub issue which might help.

How to Detect incoming VOIP calls with Sinch provider when app is offline

I am using sinch for VOIP calls. I need to know how to detect incoming calls when my app is offline or the process is killed. It can be done through background service but cannot understand how to build such service and which method can be used.
You can check the device status whether it is active or inactive
- (void)client:(id<SINCallClientDelegate>)client didReceiveIncomingCall:(id<SINCall>)call {
if (call.details.applicationStateWhenReceived == UIApplicationStateActive) {
//perform segue
}
}
Basically when the app is offline, Sinch sends a push message that should be intercepted in GcmBroadcastReceiver and then you call GcmIntentService which initializes Sinch and connects you to the call. Of course you need to setSupportManagedPush(true) and setSupportPushNotifications(true) when initializing your SinchClient.
There's a sample project provided by Sinch to help you with all this.
Just go to Sinch website and download the ANDROID SDK 3.9.3 ZIP file. It has a samples folder that contains 5 projects.
Check the project sinch-rtc-sample-push, it has the GCM implementation along with a SinchService. You can use the same classes in your project.

Using Swift 2 won't allow iOS 8 devices to Register for Push Notifications

I am configuring push notifications on for iOS using Xcode 7 and Parse. The notifications are working perfectly on a device running iOS 9.
But when running the application on a device with iOS 8, I am running into problems. I am unable to get the Alert View where the user can select to "Allow Notifications from App X".
But, the device token registration call is being called successfully when the user opts in to push notifications and the device is successfully registering an Installation object with a valid device token. Notifications are also being sent to the device.
If I go into Settings->Notifications->My App and turn the Notifications On or Off, it doesnt make a difference the notifications are still being sent through.
This is the code I am using to register for notifications:
let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType([.Alert, .Badge, .Sound]), categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
Found the solution here on stackoverflow... Registration for notifications are sent only once on devices running versions older than iOS 9.
As answered by another user here...
"The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day."
OR
"If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on."
Reference Links:
Push Notification ON or OFF Checking in iOS
https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

Query on push notification plaforms

How does push notification platforms check if the app credentials(Android - app key, project id // ios - certificate etc) provided by user are genuine or not. Do they validate this at the time of app registration or while pushing a notification on to GCM - Google cloud , APN - Apple push
I don't know the specifics for GCM but I assume it's similar to Apple: every time you try to send a push notification, you need to connect to Apple's servers with the Push Certificate that you will have generated between them and you. The validity of the certificate is checked for every single call that you make to their servers.

Resources