I am developing a mac application in which I am showing some count on app icon symbol (Similar to notification count). It work fine when app is in foreground and is active. But as an when I minimise the app or app goes into background. I am not able to see any message count on icon symbol.
let app = NSApplication.sharedApplication()
app.dockTile.showsApplicationBadge = true
app.dockTile.badgeLabel = String(unrdcount)
This method is called when I am getting data from a particular API. Can anyone suggest me how to let a particular API work for infinite time, so that if the application is ON user can get this unrdcount from API.
Related
How can I clear my Safari history and data for the iPhone simulator in an XCUITest before running the test?
I am trying to test the login features of an app and would like the login credentials not to be saved i.e. google sign in. For this I need to clear the safari history and data in the iPhone simulator settings. Is there a way of doing this in code in the setup or tear down methods?
You could do that by having a setup function that wipes the Safari data through Settings. Something like this:
func clearSafariData() {
let settingsApp = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settingsApp.launch()
settingsApp.cells["Safari"].tap()
settingsApp.cells["Clear History and Website Data"]
settingsApp.buttons["Clear History and Data"].tap()
settingsApp.terminate()
}
Simple solution: use Private mode in Safari
I want to develop an SOS application. When I am trying to use URL schema openURL(), it will display an alert but my requirement is to connect the call without any alert or popup while trying to call. So I found a solution using CallKit. When I implemented CallKit in my application it does not ask for any permission, the outgoing call is placed but the callee doesn't get any call. Is there any solution for this?
I have tried the following code for connecting the call.
#IBAction func buttonCallTapped(_ sender: Any) {
let provider = CXProvider(configuration: CXProviderConfiguration(localizedName: "My App"))
provider.setDelegate(self, queue: nil)
let controller = CXCallController()
let transaction = CXTransaction(action: CXStartCallAction(call: UUID(), handle: CXHandle(type: .phoneNumber, value: "\(number)")))
controller.request(transaction, completion: { error in })
DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 5) {
provider.reportOutgoingCall(with: controller.callObserver.calls[0].uuid, connectedAt: nil)
}
}
You just can't make standard native calls through CallKit. The CallKit framework, as clearly stated in the documentation, is meant to be used to develop custom VoIP applications and integrate them with the native phone interface.
Any iOS application can't make native call without user action.
An alert will be shown with phone number and two buttons will be available "Call" and "Cancel" which is presented from the OS level.
Just like we are showing popup to delete photos from Photos app.
Solution
If you want to implement SOS Application (Yes its possible using VoIP
service), But you can place calls when app is active (Can be done
without user action given internet connection is there.)
Note: The receiving side also should support VoIP.
How to Implement VoIP
We need permission of Voice over IP services to make calls in between iPhone devices.
VoIP app must have background mode enabled in the Xcode Project >
Capabilities pane. Select the checkbox for Voice over IP
Also CallKit is indented only for VoIP Apps, If you really want to implement the VoIP follow CallKit Tutorial
I DO NOT want to use the following:
if let url = URL( string: "tel://4151231234" )
{
UIApplication.shared.open( url, options: [:] )
}
Instead, I would like to have a list of supported URLschemes in the device that allows making phone calls. Something that would result in a list a bit like the following:
"tel://", "whatsapp://", "facetime://", "Hangout://", etc.
The problem using the "tel://" URL scheme is that iOS returns
iPhone Calls Not Available" on all devices that are not paired
with an iPhone even though they have VOIP apps that supports phone calls.
I do not want to become a VOIP app myself (using CallKit).
But I do not mind using using CallKit IF I don't implement
the entire API to become a phone app.
The Contact App has the behavior that I am looking for:
- When Selecting a contact (in the Apple's contact app),
Tap on "Call" at the top
- A pop up list of applications supporting phone calls is listed
including 'Call', "Facetime" and "Hangouts" (in my iPad).
I would like to have the list that allows the Contact app to know which apps (and also which URLschemes) can be used to make phone calls.
I bet it is simple... I just don't know ;( Help me please :<
I DO NOT want to use the following:
if let url = URL( string: "tel://4151231234" )
{ UIApplication.shared.open( url, options: [:] )
}
What would be the code to create a list of apps/URLscheme that support making phone calls?
I have a PWA application where I check whether the application is in standalone mode(code snippet below) else prompt user with the Install Banner.
let windowNav: any = window.navigator;
if (window.matchMedia('(display-mode:standalone)').matches || windowNav.standalone) {
this.isStandAlone = true;
}
Recently, I have also created a TWA app for the same. Now when I install the APP from the playstore the below check fails though the app is in standalone mode. Is there a different way to check the standalone mode in TWA applications?Or a way to check that the APP is a TWA app?
Thanks
Standalone is not so useful in case of TWA.
if u want to know that your application is running on TWA,
What you can do is set a sessionStorage as a flag,
If certain conditions met. When ever a TWA app is open u can get the package name like com.example inside document.reffer property and also you can pass some value in query Param to check ur app. Is opened.
So, this will look like this.
If(document.referrer == 'android-app://com.example' && location.href.includes('?twa=true')){
sessionStorage.isTwa = 1;
}
When app opens, a session starts, and isTwa will be set as 1, when app is closed that session ends as well. Same as a chrome tab session.
I have been trying for several months to implement an app that receives notifications whose content I want to be stored in the database of my application. I am using the Firebase Messagging plugin and I am receiving the notifications correctly, both in Foreground and in Background.
However, in the background I am unable to execute my callback without the need to press the notification explicitly by the user. Likewise, there is no way to increase the badge of the application when it is not open.
Now, I do not understand how applications like WhatsApp, Telegram and any other application that is not made by mere mortals work. How is it possible that they can get the data in backgroud, manage the badges, synchronize messages, etc? Being that, supposedly the services like Firebase are limited in background. Even with plugins like Background Mode my application is suspended by Android when the user closes it.
The code that I am currently using to handle notifications is the following:
// In foreground (WORKS)
this.firebaseMessaging.onMessage().subscribe((notificacion) => {
// Insert in DB
...
});
// In background (DOESN'T WORK)
this.firebaseMessaging.onBackgroundMessage().subscribe((notificacion) => {
// Insert in DB
...
});
What alternative is left? The only thing that occurs to me is to use notifications in Foreground and background only as a warning. So every time I open the application I'll have to call a message synchronization callback with the server (with badge management included).
If someone has some better way, I would greatly appreciate it if you throw a little light on the subject.
From already thank you very much
Ok, after more than a year I think it's time to close this question. I solved the problem this way:
Suppose I need to get a list of messages. This action is made by a function called getMessages()
When a new message is created in the backend, I send a push notification through Firebase service.
If the push notification is received in foreground I refresh call the method directly:
this.firebaseMessaging.onMessage().subscribe((notificacion) => {
getMessages();
});
If the push notification is received in background and the user taps on it there isn't a problem as it's supported by the plugin:
this.firebaseMessaging.onBackgroundMessage().subscribe((notificacion) => {
getMessages();
});
If the push notification is received in background but the user DOES NOT tap on it and opens the app in another way than the notification, we need to excecute the corresponing function when the app is opened in app.component.ts file:
this.platform.ready().then(() => {
getMessages();
// Extra stuff like this.statusBar.styleDefault(); or this.splashScreen.hide();
});
That way all the cases are considered! You should keep in mind that apps like Whatsapp or Telegram are developed in official technologies like Java or Kotlin which not only have official native plugins, also its code are excecuted natively and not in a limited browser as Cordova or Capacitor frameworks do