admin

Android Play Console Upload AAB “android:exported” solution and Update SDK API 31

Step 1;

Change “targetSdkVersion”: 30 to “targetSdkVersion”: 31 in build.gradle file.

Step2:

Add all scopes in AndroidManifest.xml file => android:exported=”true” attribute.

Step3:

For onesignal add below line codes in AndroidManifest.xml file.

<activity android:name="com.onesignal.NotificationOpenedActivityHMS"
         android:noHistory="true"
         android:theme="@android:style/Theme.Translucent.NoTitleBar"
         android:exported="true">
         <intent-filter android:exported="true">
             <action android:name="android.intent.action.VIEW" />
         </intent-filter>
     </activity>

     <receiver android:name="com.onesignal.GcmBroadcastReceiver"
         android:exported="true"/>
     <receiver android:name="com.onesignal.BootUpReceiver"
         android:exported="true">
         <intent-filter android:exported="true">
             <action android:name="android.intent.action.BOOT_COMPLETED" android:exported="true"/>
             <action android:name="android.intent.action.QUICKBOOT_POWERON" android:exported="true"/>

         </intent-filter>
     </receiver>
     <receiver android:name="com.onesignal.UpgradeReceiver" android:exported="true">
         <intent-filter android:exported="true">
             <action android:name="android.intent.action.PACKAGE_REPLACED" android:exported="true"/>
         </intent-filter>
     </receiver>

Check Merged Manifest. There should be no error.

See you!

How to deploy Asp.net Core app to Linux Droplet

Steps;

Connect to server

ssh root@<Your Server IP>

.Net sdk install on server,

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install -y dotnet-sdk-3.1

Let’s create the path;

sudo mkdir /var/www/
sudo mkdir /var/www/
sudo chown -R dries:www-data /var/www/

Let’s clone our project here

git clone <your repo git address.git>

Build and publish project

dotnet build
dotnet publish

Install nginx

sudo nano /etc/apt/sources.list

deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx

sudo apt-get update
sudo apt-get install nginx

sudo service nginx start

Welcome Nginx message when enter url with Your server ip

Add an SSL certificate with Certbot

sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx
sudo certbot --nginx

Forward requests to our app

sudo nano /etc/nginx/sites-available/sites.com
server {
    listen        80;
    server_name   ;
    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

linked,

sudo ln -sf /etc/nginx/sites-available/sites.com /etc/nginx/sites-enabled/
sudo nano /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
http{
    ...
    include /etc/nginx/sites-available/sites.com;
}
sudo service nginx restart

Create service

sudo nano /etc/systemd/system/dotnet-project-name.service
[Unit]
Description=My application service

[Service]
WorkingDirectory=/var/www/
ExecStart=/usr/bin/dotnet /var/www//.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

In my case,

[Unit]
Description=My application service

[Service]
WorkingDirectory=/var/www/oguzhanabali-dev-demo-web
ExecStart=/usr/bin/dotnet /var/www/driesdeboosere-dev-demo-web/Oguzhanabali.Dev.Demo.Web.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=oguzhanabali-dev-demo-web
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

Permission access to folders,

 

sudo chown -R root:root /var/www/
sudo setfacl -R -d -m u:root:rwx,g:root:rwx,o::r /var/www/
sudo service oguzhanabali-dev-demo-web start
sudo systemctl | grep oguzhanabali-dev-demo-web

That’s it! Now your web server will keep running your ASP.NET Core app, even if you exit the server.

Terminal Environment on macos (Unix commands,Git,Fish,Autocomplete)

1- Bkz: https://github.com/jorgebucaran/awsm.fish

2-Fish-shell install https://github.com/fish-shell/fish-shell

3-Oh-my-fish install https://github.com/oh-my-fish/oh-my-fish

4-Fisher install https://github.com/jorgebucaran/fisher

omf install bobthefish (themeinstall) 

https://github.com/oh-my-fish/oh-my-fish/blob/master/docs/Themes.md

5-Z install -(folder manager)

6-Fish manuel config, insert alias.

Create custom config file for Docker and Dotnet cli run on ubuntu terminal

nano ~/.config/fish/config.fish in
alias gg="git push"
alias gm="git commit -m"
alias gma="git commit -ma"
alias gp="git pull"
alias gpr="git pull --rabase"
alias gcb="git checkout -b"
alias gs="git status"
alias gl="git log --n 5"

set fish_greeting Go, go go..!

Then active fish config:

source ~/.config/fish/config.fish

Customize vscode theme, material-theme active.

fisher install franciscolourenco/done

fisher install rodrigobdz/fish-apple-touchbar

Finished.

Hint! AdminLte – how to fix active sidebar

$(document).ready(function() {
  /** add active class and stay opened when selected */
  var url = window.location;

  // for sidebar menu entirely but not cover treeview
  $('ul.nav-sidebar a').filter(function() {
      return this.href == url;
  }).addClass('active');

  // for treeview
  $('ul.nav-treeview a').filter(function() {
      return this.href == url;
  }).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open').prev('a').addClass('active');
})

ScreenShot Download from Webbrowser with C#

This method;
It takes a screenshot of the page you are on.

private void DownloadScreenShotImage()
        {
            int width, height;
            width = webBrowser1.ClientRectangle.Width;
            height = webBrowser1.ClientRectangle.Height;
            using (Bitmap image = new Bitmap(width, height))
            {
                using (Graphics graphics = Graphics.FromImage(image))
                {
                    Point p, upperLeftSource, upperLeftDestination;
                    p = new Point(0, 0);
                    upperLeftSource = webBrowser1.PointToScreen(p);
                    upperLeftDestination = new Point(0, 0);
                    Size blockRegionSize = webBrowser1.ClientRectangle.Size;
                    graphics.CopyFromScreen(upperLeftSource, upperLeftDestination, blockRegionSize);
                }
                image.Save("d:\\Test.bmp");
            }
        }

Hell yeah!