I'm using AgoraKit to build a voice call app 'VOIP' long side with CallKit.
When I'm trying to put the same channelId on 2 different devices and make join to channel, everything is going well.
What I want to do is to make the first device call the second one by defining a UID, So the second device will ring when ever the first one called it.
The problem is that I can't define a specific id for the device to call it, I looked up on Google for all the tutorials about joining a call with callKit even the code samples on Agora didn't help.
In another word, I'm trying to make the same logic as Messenger app, when ever the user call another user it should be going to ring.
Any idea would be helpful, thanks.
This is the function inside of the VoIP where you can find a unique device id. On the bases of this id you can make a call to other person.
// Handle updated push credentials
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) {
// Register VoIP push token (a property of PKPushCredentials) with server
}
this is the link
Related
Im trying to find a way to de-authorise users for push notifications when they log out from an app Ive found this function UIApplication.shared.unregisterForRemoteNotifications() which aparently works however I never see notifications being disabled, I also read in the documentation that it should not be used often or something to that effect, I basically want to have a toggle button in my app where the user clicks it one way and gets the standard enable notifications popup and another way to disable notifications on the fly, Im not a native swift developer so any pointers welcome
Also is it possible to attach a callback to this to know if it executes successfully, Im trying the following but get the error Argument passed to call that takes no arguments
UIApplication.shared.unregisterForRemoteNotifications() { (result, error) in
if let error = error {
call.error("Error", error)
} else if let result = result {
call.success([
"deregister": true
])
}
}
Edit: I found this which says its not possible to toggle on and off Change push notifications programmatically in Swift
With that in mind does this mean that the standard for devices is that:
1) when a user log out of their account they can still receive notifications.
2) When a user creates a new account on the same app it uses the same token and so receives notifications from the old account ?
3) when a user sells their phone and another guy/gal downloads the same app that they will receive notifications from that other users account (in terms of 3rd party push service one signal, aparently you dont need to refresh the player id)
Working on a Swift chat application.
On one device, I join a channel with unique name "private:chat", and then I call channel.typing() on the channel (as is mention in docs).
On another device, I again create a client with a delegate set to self:
TwilioChatClient.chatClient(withToken: token, properties: nil, delegate: self) { (result, chatClient) in
self.client = chatClient
}
And then I implemented typingStartedOn delegate method to listen to typing on the channel.
func chatClient(_ client: TwilioChatClient, typingStartedOn channel: TCHChannel, member: TCHMember) {
print(">>>>>>>>>>>>> typing on \(channel.uniqueName) by \(member.identity)")
}
However, the delegate method does not get called, even though I confirmed that the channel.typing() gets called by the other account on the other device. The docs inline code in JS, but based on iOS chat demo app I came to conclusion that in Swift the delegate methods are the way to go.
Any idea what might be going on here?
EDIT: Some (haven't tested all) of the other delegate methods, such as synchronizationStatusUpdated, are getting called.
So after all, the issue was not in the iOS client, but in our implementation of the access token server.
As #rbeiter noted in his comment on GitHub issue, Twilio does not send typing indicator if the user identity is the same on both devices. I was setting the identity properly on both devices to keep it different, but our access token server ignored the identity parameter and used a hardcoded value. Thus from Twilio viewpoint, the same user was on both devices. Fixing the access token server fixed the problem.
If any number is saved in my application and That user call me on my iPhone then I want to invoke my application with screen where user can fill the information about that calls.(Like Call duration,Caller Name and Some application specific details)
Please guide me how to achieve log a call in iOS. I am not sure that Apple allow us to get the information about the call which is done by normal dialer not by my application.
I have find this link : Call history, SMS history, Email history in iOS
But I want to invoke my application on incoming call if that user contact number is saved in my application.
Please help me or suggest me the solution or whether it is feasible or not.
iOS 10 +:
Use Callkit, and check it out call directory extension
Below method is called : Only when the system launches the app
extension and not for each individual call, you must specify call
identification information all at once; you cannot, for example, make
a request to a web service to find information about an incoming call.
Use the addIdentificationEntry(withNextSequentialPhoneNumber:label:) method.
class CustomCallDirectoryProvider: CXCallDirectoryProvider {
override func beginRequest(with context: CXCallDirectoryExtensionContext) {
let labelsKeyedByPhoneNumber: [CXCallDirectoryPhoneNumber: String] = [ … ]
for (phoneNumber, label) in labelsKeyedByPhoneNumber.sorted(by: <) {
context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
}
context.completeRequest()
}
}
According to Apple:
Identifying Incoming Callers When a phone receives an incoming call,
the system first consults the user’s contacts to find a matching phone
number. If no match is found, the system then consults your app’s Call
Directory extension to find a matching entry to identify the phone
number. This is useful for applications that maintain a contact list
for a user that’s separate from the system contacts, such as a social
network, or for identifying incoming calls that may be initiated from
within the app, such as for customer service support or a delivery
notification. For example, consider a user who is friends with Jane in
a social networking app, but who doesn’t have her phone number in
their contacts. The social networking app has a Call Directory app
extension, which downloads and add the phone numbers of all of the
user’s friends. Because of this, when the user gets an incoming call
from Jane, the system displays something like “(App Name) Caller ID:
Jane Appleseed” rather than “Unknown Caller”.
Can I use Parse.com’s push notification feature to send an array of PFObjects to the user when either a new one is added, or an existing one is deleted?? If so, how should I go about it? I’m writing an app for iOS. Any help would be much appreciated.
Edit:
After doing a bit of searching, I see I have to use the cloud code aftersave() method, and then send a push notification through JavaScript.
If anyone could provide examples of how to go about it, that would be great. In the meantime I'm going through the docs. Thanks again all.
The Parse Documentation really contains everything you need to get started. Writing the code that sends the actual notification is only a small part of the whole process that is required to send push notifications. Here are the steps required:
Create an SSL Certificate: create the cert via Apple Developer Center then export it with Keychain Application
Create Provisioning Profile: also done via Apple Dev Center.
Configure Parse App: Change Parse settings, then upload the cert you created in step 1.
Configure App in Xcode: Change app to use provisioning profile you created in step 2.
Add Code to Prompt user for Notifications: write the code in your app that asks a user if they want to receive Push notifications, then store their device ID in Parse Installation class.
Send the Notification: as mentioned earlier this is the easiest step of all. It can be done via the Parse Dashboard (Click on Push notifications when looking at the Data Browser), via the Parse API or via Cloud-code. I did it via Cloud-Code and it looks like this:
// Find the Installation (i.e. iOS Device) that belongs to my user*
var query = new Parse.Query(Parse.Installation);
query.equalTo('user', user);
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: "This is the notification message",
badge: "Increment"
}
}).then( function(){
console.log("Push notification successfully sent!");
});
*I added a field in my installation class that captures a user. That way I know which device belongs to which user and can send targeted Push Notifications.
Prepare for Release: When you release your app, you will need to do some additional configuration to get everything ready to release.
Again, I recommend the Parse Docs. They are comprehensive and very helpful. Let me know if you have any additional questions. Hope this helps!
** BTW: If you don't have any experience with cloud-code, then you can complete steps 1-5, then manually send the notifications via the Parse Dashboard.
I'm creating a cloudkit app, and have been trying multiple ways to get the NSUbiquityIdentityDidChangeNotification, but I never am able to get this notification.
I've tried both of these code versions under the delegate didFinish and the viewDidLoad methods. And I tried calling it from another notification - UIApplicationDidBecomeActiveNotification. I also put import Foundation at top of files.
Here's the basic code I've tried:
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "handleIdentityChanged:",
name: NSUbiquityIdentityDidChangeNotification,
object: nil)
// And this one I tried too from another post here on SO:
var localeChangeObserver = NSNotificationCenter.defaultCenter().addObserverForName(NSUbiquityIdentityDidChangeNotification, object: nil, queue: NSOperationQueue.mainQueue()) { _ in
println("The user’s iCloud login changed: should refresh all user data.")
}
Does anyone know how to get this notification to work for only a cloudkit app in swift? I really just want to detect the iCloud status change and then initiate fetching the userID if there's been a change.
Not that I need to access the ubiquityIdentityToken, but I was wondering why not store the token and every-time the app starts compare the current token with the one in local storage to see if it's a different account or nil? Therefore, why is getting the notification necessary?
Also, the code for getting the token only seems to work if I turn on "iCloud Documents", which I don't need. Does anyone know the implications of having that turned on for a social app that doesn't need it? And is there another way to get the token without enabling iCloud Documents?
This is the code I used to get token and placed in the delegate didFinish method, but only works if iCloud documents is turned on:
var token = NSFileManager.defaultManager().ubiquityIdentityToken
println("token is \(token!)")
On iOS, when I sign out of iCloud, my app is killed. So there seems not really to be a need to receive a NSUbiquityIdentityDidChangeNotification. Like you have said, it seems to be sufficient to compare the current token to the saved token.
On the Apple TV though, my app was not killed when I logged out of iCloud. Here I had noticed the notification was not fired, like you described. Since the app is not killed, a notification would be in order. (Did Apple forget to kill apps on Apple TV when iCloud account is changed?)
With Apple TV there is no iCloud documents container available (unless I explicitly share one from an iOS app). I found that on the dev center website, for the app identifier, iCloud was shown as "Configurable" and not "Enabled" if no document container was selected. I wonder if this has an effect on receiving notifications.
Both on the Apple TV and iOS, I can also confirm that the iCloud token is nil when not using documents (here: key-value-store only). Now that makes it difficult for Apple TV apps (because the app is not killed on iCloud account change, like on iOS) to detect account changes.
I have just noticed that my Apple TV app does received several NSUbiquitousKeyValueStoreDidChangeExternallyNotification when I log into another iCloud account, to reflect the changes. I guess this is as good as it gets. These notifications come with the NSUbiquitousKeyValueStoreChangeReasonKey key in userInfo, and a value of NSUbiquitousKeyValueStoreAccountChange indicates the account has changed.
Sorry for not being able to provide a direct solution, maybe it helped to share my experience.
To be notified in iOS when a user logs in or out of iCloud while using your app, use CKAccountChangedNotification instead of NSUbiquityIdentityChanged notification.
(Longer explanation: https://stackoverflow.com/a/38689094/54423.)