Can "presence_query" be used in the new slack app? - slack-api

I want to query the presence of users in a Slack workspace.
Using the old (classic) app, I can do it using presence_query via Slack RTM.
However, RTM requires depracted bot scopes (and the old classic app).
Can I use (and how) presence_query with the new slack app (I'm using python)?
This is my current implementation (using the old classic app):
from slack_sdk.rtm_v2 import RTMClient
rtm_client = RTMClient(token='SLACK_BOT_TOKEN')
#rtm_client.on("presence_change")
def receive_presence_changes(client:RTMClient, event:dict):
print(event)
rtm_client.connect()
rtm_client.send(
payload={
"type" : "presence_query",
'ids' : ids_list,
}
)

No, there are currently no ways to subscribe to presence-oriented events on the Events API or via Socket Mode. The legacy RTM API is the only avenue still available.

Related

Does electron's registerHttpProtocol work in development?

I'm trying to register a custom protocol with electron. I want it to be a redirect location that a website can use to provide an api key (like myprotocol://example/payload=api-key). I have been using electron's registerHttpProtocol and also tried electron's interceptHttpProtocol.
But, when the website tries to redirect to my protocol my electron app doesn't do anything. The website goes to myprotocol://example/payload=api-key, and registers a "page doesn't exist error"--while nothing happens in my app.
This is in a development environment. I've seen some discussion about custom protocols that assume a production environment.
Can you register a custom protocol with electron in development?
Why am I not able to intercept the website's going to the protocol I've set out?
Here's my code:
main.js:
app.whenReady().then(() => {
protocol.registerHttpProtocol('examplep', (request, callback) => {
console.log("examplep", request);
callback('it-worked');
}, (error) => {
if (error) console.error('Failed to register protocol = ' + error)
})
protocol.interceptHttpProtocol("examplep", function (request, callback) { //I've tried both registerHttp... and interceptHttp... methods, so including both here; though I think in practice only one should be required
console.log('intercepted!' + request)
callback(request);
});
})
redirect url provided to website:
'http://examplep'
And I've whitelisted this url on the website itself.
I've also tried related methods registerStringProtocol, interceptStringProtocol, registerFileProtocol, and interceptFileProtocol, without success.
What am I missing?
Sounds like you need to support deep linking fora desktop app, which is done via a Custom URI Scheme and is registered with setAsDefaultProtocolClient.
When your Electron app starts up write this code to register the scheme, on the main side of your app:
const customScheme = 'x-mycompany-myapp';
app.setAsDefaultProtocolClient(customScheme);
The custom scheme can be tested from the command line like this, depending whether you are running macOS or Windows:
open x-mycompany-myapp:/some/location
start x-mycompany-myapp:/some/location
A web client will just invoke a URL as in this Javascript code of mine;
The notification will be received within the main side of your app and on Windows will attempt to create a new instance of the app, in which case you need to detect this condition, process the notification then cancel the new app instance.
On MacOS it will be received within the open-url event, so you register it like this:
app.on('open-url', this._onOpenUrl);
Once the main side of the Electron app has the notification, it needs to get the URL information and forward it to the renderer process. You can use ipcMain events for this.
Finally the code for receiving the notification in running instances and starting the app from a deep link are different.
EXAMPLE APP
Since the code is a little tricky, here is some example code that may be useful, to give you something to compare against. If it helps you can also run the app by following the instructions in the blog post:
Code
Blog Post
My use case is around receiving OAuth responses after signing in from the system browser. Hopefully you can borrow some ideas from it related to deep linking though.
INFO.PLIST
My understand is that in a development environment (on macOS) deep links work when the app is running, but if you stop the app and attempt a deep link it will not start the app.
You can only resolve this for a packaged app, which requires an info.plist. In my code sample the info.plist is generated from build protocol entries in the package.json file.
My code sample is packaged in a basic way by the Electron Packager, so when I run npm run pack, the app is built to a dist folder. I can then run the packaged version of the app and it gets registered with the system - as can be seen in the Default Apps tool. See screenshots in the blog post.
SECRETS
Secrets for a desktop app should be stored using operating system secure storage. There are screenshots of credential storage in the blog post.
On Electron, have a look at the keytar component - and this wrapper class of mine. I am storing tokens (strings) so you should be able to adapt the code for your API keys.

Xamarin forms how to log in with Apple account

I'm trying to publish my first xamarin forms app on IOS. I barred the issue of login with the Apple account.
I have 4 questions, please.
1- If I implement Sign in with Apple only for IOS 13+ will it be accepted? :(
2- I'm trying to use Xamarin Essentials to log in to IOS 13+ as shown in this article:
Xamarin Essentials
// Use Native Apple Sign In API's
r = await AppleSignInAuthenticator.AuthenticateAsync();
But I only get back the idToken. AccessToken, name and mail return null. Am I missing something?
3 - And finally I tried to use the plugin.firebaseAuth version 4.0.0-pre01:
Link plugin
// For iOS
var credential = CrossFirebaseAuth.Current.OAuthProvider.GetCredential("apple.com", idToken, rawNonce: rawNonce);
var result = await CrossFirebaseAuth.Current.Instance.SignInWithCredentialAsync(credential);
// For Android
var provider = new OAuthProvider("apple.com");
var result = await CrossFirebaseAuth.Current.Instance.SignInWithProviderAsync(provider);
It provides an example using prism to deal with this, but when I install the plugin in this version the application is no more than a splash screen and closes, without showing an error in the output. What am I doing wrong? :(
The first link seems promising for iOS less than 13 and Android using Asp.NET. However in the application I use only the Firebase ClouFirestone and Firebase Hosting for the Administrative Panel. Is it possible for me to sign in Apple without the services of a different backend?
I am very grateful for any light on the path I must follow
1- If I implement Sign in with Apple only for IOS 13+ will it be accepted?
It depends, if they don't find any other issues or violation, it will get accepted.
2- I'm trying to use Xamarin Essentials to log in to IOS 13+ as shown in this article: But I only get back the idToken.
Apple will only provide you the requested details on the first authentication. After that first authentication, you will only get the User Id so be sure to store the details that first time in case you need them.
This feature needs to be tested on a physical device running iOS 13. The simulator is not reliable, it doesn’t always work properly.
Should follow the design guidelines when implementing Apple Sign In. You can find it here: https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/

Is it possible to make an uber-like map tracking using PubNub?

I have been trying to make a web app that has a certain feature like uber where users can see other users on a map. I read about pubNub (https://www.pubnub.com/) and I saw they have a tutorial that allows you to track movements on a map https://www.pubnub.com/tutorials/javascript/mapping-javascript-tracking/.
They also provide a tool called presence (https://www.pubnub.com/products/presence/) which allows you to see if users have joined your web session or not. I would like to, with presence, to show on a map if people have joined the session or left the session. If they are on the map, I would like the movements to be updated as well.
I am just wondering if someone has used pubNub before to achieve something similar and if so how to go about it?
Clone Uber with PubNub and EON Maps
https://github.com/pubnub/pubnUber - GitHub Repository
Today we're going to use Phonegap and PubNub to create a simple taxi hailing app. What we'll walk through today is the same technology stack used by Uber, Gett, and other taxi hailing apps. They all work in a similar fashion.
Getting started
Install phonegap on the CLI.
Clone this repository locally.
The repo contains two directories /rider and /driver. We're going to start with /driver.
Set Up PubNub
First, we need to set up PubNub. the PUBNUB variables comes for free from the EON library. The publish_key and subscribe_key settings come from your PubNub account.
var channel = "pubnub-taxi-app";
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
The pubnub plugs the same pubnub variable we configured in the first step into EON. This lets us use our own PubNub keys within EON.
Our Mapbox configuration is set and we're ready to send some
Publish messages to the channel
Define our PubNub channel.
Subscribe.
pubnub.subscribe({
channel: channel,
message: function(message,env,channel){
if(message == 'hail') {
var pickup = confirm("Someone requested a ride!", "Accept");
if(pickup) {
pubnub.publish({
channel: channel,
message: 'pickup'
});
}
}
}
});
And here is the hail() function.
var hail = function(argument) {
pubnub.publish({
channel: channel,
message: 'hail'
});
alert('Waiting for driver...');
};

Microsoft Live SDK OneDrive ios multiaccounting

If you have experience working with Microsoft OneDrive (ex SkyDrive) using their official live-sdk - have you faced a problem of multi-accounting?
Just on MS forum I found this post (And so I do want to make the same task):
"I'm working on an IOS app using one drive sdk and i need to do a multi connection so user can add more than one account , and then when he click on the account icon i account will be opened , so my idea to do this was to save the accessToken ,authenticationToken,refreshToken,scopes,expires of each account then i will create the LiveConnectSession object using the method :
initWithAccessToken:(NSString *)accessToken
authenticationToken:(NSString *)authenticationToken
refreshToken:(NSString *)refreshToken
scopes:(NSArray *)scopes
expires:(NSDate *)expires;
then i will set it to the LiveConnectClient , but the broblem is that the session proprety of LiveConnectClient is read only so i cant change it "
So the MS support tells, that right now it is impossible, but still there are apps, that provide multiaccounting
So now I'm confused.
I will be happy to hear any response.

Interacting my lua app (LuaSocket) with my socket.io chat example server

I am writing an app for Corona SDK (Using LuaSocket) to be able to subscribe and post messages to the example chat server that runs in socket.io (using gevent-websocket 0.9).
I have checked that chat.js on the server interacts with ther server like this:
To subscribe to a room:
socket.subscribe('room-2000')
Or interacting with the chat room:
socket.send({room: 'room-2000', action: 'start', name: 'John'})
socket.send({room: 'room-2000', action: 'message', message: 'hi there!)});
etc..
Full js client script.
But I don't find a way to make an app for Corona SDK to interact with a channel. I managed to connect to the server with:
socket.connect( my_ip, my_port)
But cannot find a way to subscribe or post/receive messages, can someone give me a clue? Will be highly appreciate it.
AFAIK, you need to do a WebSocket handshake. Read the WebSocket specifiation.
Otherwise, I can recommend you this Publish/Subscribe library for CoronaSDK/Nodejs
https://github.com/Overtorment/NoobHub

Resources