I am developing an ios app using Sinch with swift and notifications are showing when the app is working in background but when I close the app, notifications won't show up. All resources in Sinch docs are in Obj-c that's why I am asking this question in here. Is there anybody worked with Sinch using swift and can explain to me little bit.
Its actually not a swift thing at all, it applies to objective c as well :D
When you open the app and you have pushed a notification (or not) you will receive a regular on message recieved to you MessageClient delegate, when you get that and are not in the chat screen you need to decide what you want to do, either show in in app notification or take the user to that screen (I suggest showing an in app notification)
Related
I am using OneSignal to send Push Notifications to my React Native App. On receiving notification I bring up a Custom React Native screen to take some input from User.
I followed the instructions mentioned here:
https://documentation.onesignal.com/docs/react-native-sdk
https://documentation.onesignal.com/docs/react-native-sdk-setup
The above two guides mainly explains how to Initialize OneSignal, setup notification listeners and other required Native settings.
After the above configuration I am able to send Notification (and bring up the Custom Screen) to App on iPhone but only if App is in Foreground. The App was not receiving notification if in Background.
Then I followed the below article by Oleg Kalyta and configured:
https://hackernoon.com/complete-guide-receive-push-notifications-in-react-native-ios-app-38b1ec5b1b15
It explains how to configure PushNotificationIOS RN package and setup some more functions and listeners. Though I don’t quite understand why I need these functions if I have already configured OneSignal listeners. And how it will impact on my App’s performance with too many listeners.
After this configuration I am able to receive notification (it comes at top of iPhone and goes away after 2-3 seconds) even if the App is in Background. But it does not bring my App in Focus and does not show Custom screen.
I am looking for help to resolve the issue and show the Custom screen if App is in Background and it receives notification.
Interestingly the OneSignal listeners are getting called and I am also able to see the sent data in the logs but I am not sure how to bring up the IOS App in focus.
In Android I am able to even unlock the phone and bring the App in focus on receiving notification. I have written some Android Native code using Android PowerManager and WindowManager packages. I am calling this native code from my React Native OneSignal listener to Wake up the phone and bring the App in focus and display the custom screen.
The same thing I am trying to achieve in IOS.
Please can anyone help. I have gone through lot of articles on Net but I am not able to find any solution.
I'm currently working on implementing push notification for my app using React Native and OneSignal. I've managed to set the settings for Android and iOS, but I noticed the iOS side keeps disappearing from time to time and appearing again. Same thing with the dashboard, the iOS logo sometimes appear and disappear.
When trying to send notification while only targeting my iOS device, sometimes the system would show Total Number of Recipient to be 0 as well. The device itself only received the notifications from time to time while the android side always received them.
Anyone ever have this issue as well? And did you managed to solve it?
EDIT:
I cannot seem to find a way to fix this so I decided to do a workaround instead by creating another project inside OneSignal and disable the old one. The push notification is working fine now.
OneSignal fixed this issue today with the dashboard not saving/persisting data. You should be able to save your settings now. Best to contact OneSignal directly with issues like this.
Previously, when building my app using the iOS 9 SDK, the push notification authorization request alert (that system alert which says: "App" Would Like to Send You Notifications ... Don't Allow / Allow) would only show when I called [[UIApplication sharedApplication] registerForRemoteNotifications].
We've decided to actually only do that at a certain point in the game, so the user is only encouraged to allow push notifications when it makes sense.
On iOS 10, I understand we must use the User Notifications framework to accomplish that (by calling requestAuthorizationWithOptions:completionHandler: on [UNUserNotificationCenter currentNotificationCenter]), enable Push Notification on the app Capabilities and setup the entitlements. And that does work on some devices, but not all of them.
On some devices, the authorization request is presented to the user right at app launch even though I did not call requestAuthorizationWithOptions:completionHandler: or registerForRemoteNotifications at any point yet.
The weirdest part is that this happens consistently on some devices (running iOS 10.1.1 or 10.2 beta), even if I install the AppStore version of the app (which was built using Xcode 7 and iOS 9 SDK).
Should I assume this is a bug of iOS 10? I couldn't find other people with the same issue, only a kinda similar issue here.
The issue is actually a change from iOS 9 to iOS 10 on Game Center's [GKLocalPlayer localPlayer].authenticateHandler.
When it is set, it will trigger a push notification permission request on iOS 10. This did not happen on iOS 9.
For anyone stumbling upon this and not finding the above answer to have been the cause of their problem, it should be noted that attempting to change the app badge will also result in a Push Notification request.
My personal situation was regarding a Cordova app, where I was loading and applying the badge plugin before initialising push, and couldn't work out why the Notification permission dialog was appearing on app launch.
Currently there are 3 flavors of notifications in the Apple Watch:
Short - You can't customize these at all.
Static - You can customize these on the Storyboard.
Dynamic - Can customize UI elements with new data not coming on
the Notification payload.
Here's the problem (The project is using Watch OS 1), if the app was never opened from the Apple Watch the Static notification will be displayed instead of the Dynamic one and the log will show the error
Took too long to show custom notification. Falling back to static
I've stripped down the notifications code & ViewController to nothing but this:
-(void)didReceiveRemoteNotification:(NSDictionary *)remoteNotification withCompletion:(void (^)(WKUserNotificationInterfaceType))completionHandler
{
completionHandler(WKUserNotificationInterfaceTypeCustom);
}
And I was still getting this error.
I must clarify that after the app runs from the watch at least once every thing is working as expected and Dynamic Notification Interface are displayed fine.
Things i've double checked:
Watch battery is above 70%
This is the only code in my didReceiveRemoteNotification
WKUserNotificationInterfaceController subclass is connected to the
Dynamic interface Controller in my storyboard file
I've searched the Apple docs for something that verify this behavior and couldn't find anything related. At first I thought that something was not configured correctly with my app but then discovered that this is common in all Apple watch apps i've tried.
Steps to reproduce:
Download an Apple watch app that was never installed on your device and that uses Dynamic notifications. (I've tested this on Telegram and Outlook for example)
Don't open the app from the watch, only from your phone.
send your self a push notification.
The notification will arrive to your watch as Static notification and the Devices log will show the "Took too long to show custom notification. Falling back to static" error.
Open the app from the watch and send another notification. This will arrive as Dynamic.
After the Watch app is opened at least once the above is very hard to reproduce. Deleting the app from phone & watch and reinstalling everything still displayed Dynamic notifications as it should.
Is anyone experienced that?
Is there a way to display dynamic notifications without opening the app at least once on the watch?
I've an app with a today extension and a watch app. From the main app WCSession works fine and data is transferred to the watch and received correctly but when I try to send or receive data through the WCSession in the today widget the property paired and watchAppInstalled of the session are set to false so calling transferUserInfo: does nothing and session:didReceiveUserInfo: is never called.
I know I can open the app using openURL and then send the new data but I want to do that without leaving Notification Center.
Does anyone know a nice workaround for this problem?
It seems WCsession only works from the iOS app, not from any iOS extensions (share, today, keyboard, etc.), so for now you'll have to "relay" things via the app if you want to get it to the watch.
You should file an enhancement bug report with Apple explaining why you think it should be possible to use it from extensions too!
If the watch app is running in the foreground, you should be able to send it a message via a Darwin notification. Take a look at MMWormhole.