<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hrishikesh Sharma</title>
    <description>The latest articles on DEV Community by Hrishikesh Sharma (@hrishikeshps).</description>
    <link>https://dev.to/hrishikeshps</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F500662%2F6489d188-941d-4627-8ab3-458adf47c8ac.jpg</url>
      <title>DEV Community: Hrishikesh Sharma</title>
      <link>https://dev.to/hrishikeshps</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hrishikeshps"/>
    <language>en</language>
    <item>
      <title>Send Slack Notifications via NodeJS</title>
      <dc:creator>Hrishikesh Sharma</dc:creator>
      <pubDate>Sun, 09 Jul 2023 15:07:14 +0000</pubDate>
      <link>https://dev.to/hrishikeshps/send-slack-notifications-via-nodejs-3ddn</link>
      <guid>https://dev.to/hrishikeshps/send-slack-notifications-via-nodejs-3ddn</guid>
      <description>&lt;p&gt;Slack has always been a leading project management tool used by project developers, managers and founders. &lt;/p&gt;

&lt;p&gt;While working on a project, it is very useful to setup a common notifier system for a number of key reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One wants to be notified when a new user signs up 🚀&lt;/li&gt;
&lt;li&gt;One wants to be alerted when a user was trying to complete an action and they encounters error 😑&lt;/li&gt;
&lt;li&gt;One wants to be alerted when a user pays up for any in-app purchases, subscriptions etc. 💸&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these notifications in place, it helps to keep the team notified so that everyone is on the same page!&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's setup the &lt;strong&gt;'Slack App'&lt;/strong&gt; first:
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://api.slack.com/apps" rel="noopener noreferrer"&gt;Slack API Page&lt;/a&gt;  and click the "Create New App" button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpg3zksc2h721lqdwfrrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpg3zksc2h721lqdwfrrb.png" alt="create slack app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select 'From scratch' and provide a name of your app and then choose the desired workspace.&lt;/p&gt;

&lt;p&gt;Under Basic Information section, under “Add features and functionality” section, click on “Permissions” tab, you will be redirected to "OAuth &amp;amp; Permissions" page under which scroll to "Scopes" section, and select the permissions shown in the screenshot below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn67kkhucs22pnbgy2vbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn67kkhucs22pnbgy2vbe.png" alt="slack channel app permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once those permissions have been added, scroll up to fetch the OAuth token which will be later used in the app for sending the notifications. &lt;/p&gt;

&lt;p&gt;Note: OAuth token is provided after the app has been installed on your workspace (the one which you selected while creating the app.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8pcgxphs6g1gny2bxb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8pcgxphs6g1gny2bxb0.png" alt="slack app installation for oauth token"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking on the "Install to workspace" button, you'll see the page below, kindly Allow the installation. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsihxbwe4hn126wro1b6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsihxbwe4hn126wro1b6.png" alt="slack app installation to workspace"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After allowing to app to install, you'll be redirected back to the same page and this time, oauth token will be visible now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbf2wmj31f3vqijzyn6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbf2wmj31f3vqijzyn6y.png" alt="token for the slack app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the OAuth token and next we'll fetch the channel id, under slack, open the channel and click on the channel name and you'll see the popup shown below,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksd2aerekenlcq5t87ne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksd2aerekenlcq5t87ne.png" alt="slack channel id"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Now let's setup the Node app now..
&lt;/h2&gt;

&lt;p&gt;Create a node app or use an existing one and run &lt;code&gt;npm i @slack/web-api&lt;/code&gt; in order to install the slack client for nodejs.  &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Create another file under utils folder by the name &lt;code&gt;slack.util.js&lt;/code&gt;.&lt;br&gt;
Then, define the &lt;code&gt;SLACK_TOKEN&lt;/code&gt;&amp;amp;&amp;amp; &lt;code&gt;SLACK_CHANNEL_ID&lt;/code&gt; in your &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 

&lt;p&gt;Now, run the code, and while running, if you see the error below, then it is because we have to make the app join the channel as well. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hdz6ukjnz485ntbzj0i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hdz6ukjnz485ntbzj0i.png" alt="not in channel error from slack client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in order to make user join the channel, check the snippet below,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

const resp = await web.conversations.join({
    channel: channel,
});
if (message) {
    await sendSlackMessage(message, channel);
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After using the code above, lets trigger the notification and voila!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhi8vgpauvedqatcb08qy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhi8vgpauvedqatcb08qy.png" alt="slack notification triggered"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The full code is available for your reference &lt;a href="https://github.com/hrishikeshps/slack-notifier-node" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Further, you can create an API to fetch the active channels from slack and then make channel selection dynamic directly from your app. Let me know if you have some questions.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>node</category>
      <category>slack</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to debug React Native WebView</title>
      <dc:creator>Hrishikesh Sharma</dc:creator>
      <pubDate>Thu, 29 Jul 2021 03:42:48 +0000</pubDate>
      <link>https://dev.to/hrishikeshps/how-to-debug-react-native-webview-18cp</link>
      <guid>https://dev.to/hrishikeshps/how-to-debug-react-native-webview-18cp</guid>
      <description>&lt;p&gt;Assuming that you have already started working with React Native and possibly began to check how to debug code in and out using the debug menu in devices.&lt;br&gt;
Keeping aside the traditional code and bringing focus on the WebView component only. Recently, React Native Dev made some changes in the web view repo and replaced UIWebView with WKWebView in iOS 8.0.&lt;br&gt;
Then the next change happened, if you are reading this, then you probably must know this, React Native removed WebView from its repository and made it a self-supported import. Now it exists in,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/r/?url=https%3A%2F%2Fgithub.com%2Freact-native-webview%2Freact-native-webview" rel="noopener noreferrer"&gt;React Native Web View&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, coming back to the main agenda of debugging HTML in iOS and Android devices.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For iOS&lt;/strong&gt;&lt;br&gt;
We need probably two things, an app running in any iOS device/iOS simulator with the app in debug state and Safari Developer Toolkit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To enable "Develop" mode in Safari Browser:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Safari Browser&lt;/li&gt;
&lt;li&gt;Under the Safari option, click on 'Preferences'&lt;/li&gt;
&lt;li&gt;Under the 'Advanced' tab, enable check "Show Develop menu in menu bar"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Steps for debugging:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the React Native app with WebView in iOS device/ iOS simulator in debug mode&lt;/li&gt;
&lt;li&gt;Open Safari, from the menu bar, we need to click on 'Develop' option, 'Develop' &amp;gt; {Device Name} &amp;gt; {Application Name} &amp;gt; {Title}&lt;/li&gt;
&lt;li&gt;Now you can debug the HTML rendered within the WebView&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Android&lt;/strong&gt;&lt;br&gt;
We can debug the contents of the WebView in Chrome directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps for debugging:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, we need to make some edits in the "MainApplication.java" file so that we can enable debugging, see below-attached image for importing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvellqj2chju74do5goc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvellqj2chju74do5goc9.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the React Native app with WebView in Android device or Android emulator&lt;/li&gt;
&lt;li&gt;Open Chrome, and follow the links, DevTools &amp;gt; 3 dot menu &amp;gt; More tools &amp;gt; Remote devices&lt;/li&gt;
&lt;li&gt;Select the current device and then hit 'Inspect'&lt;/li&gt;
&lt;li&gt;Now you can debug the HTML content of the WebView&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: USB debugging must be enabled in your device settings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;I was stuck at debugging the content for a while and then I referred this &lt;a href="https://github.com/react-native-webview/react-native-webview/blob/master/docs/Debugging.md" rel="noopener noreferrer"&gt;link&lt;/a&gt;. I hope it'll be a great help to you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding :)&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
