Posts
Send real time notification with Pusher using Laravel and JavascriptLaravel

Send real time notification with Pusher using Laravel and JavascriptLaravel
Here we will learn how to send real-time notifications using Pusher + Laravel.
First of all, you need to create an account in the Pusher and get API keys from there.
Setting up your Laravel application
Now we need to install Pusher SDK, you can install it by the composer using the below command,
composer require pusher/pusher-php-server
After the composer is done, we will need to configure Laravel to use Pusher as its broadcast driver, update the below variables in the .env file,
PUSHER_APP_ID=123456
BROADCAST_DRIVER=pusher
// Get the API Keys from your pusher dashboard
PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXX
PUSHER_APP_SECRET=XXXXXXX
Open config/app.phpand uncomment the "App\Providers\BroadcastServiceProvider::class".
Now we need an event that will be broadcast to the pusher driver. Let's create a NotificationEvent.
php artisan make:event NotificationEvent
This command will create a below file
namespace App\Events;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NotificationEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $username;
public $message;
public function __construct($username)
{
$this->username = $username;
$this->message = "{$username} send you a notification";
}
public function broadcastOn()
{
//it is a broadcasting channel you need to add this route in channels.php file
return ['notification-send'];
}
}
Add broadcasting route in channels.php file
Broadcast::channel('notification-send', function ($user) {
return true;
});
Cache Event at Javascript Side
// Initiate the Pusher JS library
var pusher = new Pusher('YOUR_API_KEY', {
encrypted: true
});
// Subscribe to the channel we used in our Laravel Event
var channel = pusher.subscribe('notification-send');
channel.bind('App\\Events\\NotificationEvent', function(data) {
// this is called when the event notification is received...
});
Testing and Setup
Using the below route we can send a notification.
Route::get('test', function () {
event(new App\Events\NotificationEvent('Monika'));
return "Event has been sent!";
});
How to integration google ad in android app. Part - 1Android Development

How to integration google ad in android app. Part - 1Android Development
Dear, Friend in this blog we discussion google ad integration. Many companies work in client base & product base. Product based company in very very important ad integration in the app. Multiple types of AD are available like a Facebook ad, start-up ad, google ad, etc. Today we learning google ad integration.
Type of Google AD:
- Banner AD
- Interstitial Ad
- Rewarded Video Ad
- Native Ad
1.Banner Ad
Banner Ads occupy only a portion of the screen depending on the ad size that is created. It comes in multiple sizes Standard, Medium, Large, Full-Size, Leaderboard, and Smart Banner. Smart banners are very useful when you target multiple device sizes and fit the same ad depending on the screen size.
2.Interstitial Ads
Interstitial ads occupy the full screen of the app. Basically, they will show on a timely basis, between screen transition or when the user is done with a task.
3.Rewarded Video Ad
This ad shows a video-type ad.
4.Native Ad
In this app in full description ad showing.
Create a new project
Create a new project in Android Studio from File ⇒ New Project.
Open build. Gradle and add play services dependency as AdMob requires it.
compile ‘com.google.android.gms:play-services-ads:11.8.0’
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'ccom.google.android.gms:play-services-ads:11.8.0'
}
Add the App ID and Ad unit IDs to your strings.xml.
AdMob
Interstitial
Welcome to Admob. Click on the below button to launch the Interstitial ad.
Show Interstitial Ad
Show Rewarded Video Ad
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
ca-app-pub-XXXXXXXX~XXXXXXXXXXX
Create a class named MyApplication.java and extend the class from Application. In this application class, we have to globally initialize the AdMob App Id. Here we use MobileAds.initialize()
MyApplication.java
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileAds.initialize(this, getString(R.string.admob_app_id));
}
}
Open AndroidManifest.xml and add MyApplication to tag.
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544/6300978111"/>
Performance Testing Part-1Testing

Performance Testing Part-1Testing
What is Performance Testing?
Performance testing, which is a non-functional testing method performed to determine system parameters in terms of responsiveness and stability under various workloads. Performance testing measures the quality characteristics of a system, such as a scalability, reliability, and resource use.
Types of Performance Testing
There are mainly six types of performance testing Let's see in detail.
Load Testing
It is the simplest form of testing conducted to understand the behavior of the system under a specific load. The load tests will determine the measurement of important business-critical transactions and will also monitor the load on the database, application server, etc.
Stress Testing
It is performed to find the upper limit capacity of the system and also to determine how the system is operating if the current load greatly exceeds the expected maximum.
Spike Testing
The Spike test is performed by suddenly increasing the number of users by a very large amount and measuring system performance. The main objective is to determine whether the system will be able to carry the workload.
Scalability testing
It Measures performance based on the software's ability to increase or decrease performance measurement attributes. For example, a scalability test could be performed based on the number of user requests.
Volume Testing
Under large test volume no. From. The data is filled in a database and the overall behavior of the program system is monitored. The goal is to check the performance of the software application under different database sizes.
Endurance Testing
It is done to make sure the software can handle the expected load over a long period of time.
We will see full performance testing process points in our next article, to continue...
Which Logo File Format to Use Part-2Design

Which Logo File Format to Use Part-2Design
GIF logo file formats are not as widely used as they once were. They have a very limited color spectrum (only 256 colors out of millions in JPG) so solid color logos are a good candidate for this format. A special feature of the GIF file is that it supports smooth animation. You can create frames with frame animations and file sizes will be negligible as long as you keep the color flat and smooth (from red to blue). GIF files are pixel-based and do not expand well.
EPS and AI logo file formats are a sacred grail of file formats. They are made up of dots and lines, not pixels, allowing infinite scaling and expansion without losing quality. Many business owners and executives ignore these logo file formats because they cannot open them normally. Many common MS Office fee programs do not open the EPS logo file format. EPS files can also support pixels, which also makes this file format difficult. Software such as Adobe Illustrator, InDesign, or Photoshop can work with this file format and optimize and save almost any logo file format you need. Illustrator will allow resizing, color mode change, and more.
PDF logo file formats can also be difficult as PDF color mode can disguise spectra and resolution. Some common office fee software will open or import PDFs but one way to tell if the resolution is good is to zoom in very closely to the logo. If the edges stay crisp, you’re in business and a graphic designer who can use something in print and digital applications. If the edges become blurred or pixelated, you will be limited in the use and extension of this particular logo file format.
SVG files have become more common on websites and digital access and are considered the standard format for displaying vector graphics on the web. SVG logo file formats allow a resizable logo format that does not lose image quality as it is expanded or reduced. This is especially important with responsive web design where the logo file can be resized depending on the digital device the website is viewing. Another major advantage for the SVG logo file format is the relatively small file size - which allows a digital file to load on a website very quickly. Support is limited to SVG but website design is an important place for their use.
How to Generate Sales LeadsSales

How to Generate Sales LeadsSales
Many successful small business owners are constantly looking to expand their customer base and grow their businesses. However, business growth can be a difficult and long-term process. One of the key elements of growing a business is constant access to a steady stream of sales leads. A lead is a person or business if you have a company that sells to other businesses that are interested in the products or services you sell.
Here are some tips for building a system that will help you identify sales leads in your small business, and - with the right focus and effort - turn them into customers.
1. Increase your engagement with your customers
Relationships are all about sales and talking to the people who reach out to you to do so. For example, when people reach you with questions about your product or company, instead of just mentioning them on your blog, you can ask them if they mind having a quick chat with you.
2. Constantly refresh your email lists
It is impossible to generate leads from an old email list that contains incorrect information or does not match the parameters of your target person. If you haven't cleaned up your email list for a while, you may still be cold-emailed people who are already your customers.
3. Use chatbots on your website
Customers want to do business with companies that respond promptly to questions. Although companies respond within 12 hours on average, research shows that consumers expect responses within 1 hour. You might think, "Well, but they know we're not working right now," or, "They'll surely understand that we're in another realm of time." While customers can understand and understand later, there are thousands of businesses offering services just like yours, so you don't want to take that opportunity.
4. Join and participate in social media groups
LinkedIn and Facebook are great places to connect with other professionals, share your skills, and find leads. Once you join a group, don't start by pitching members as this can cause people to separate. Instead, do the following to establish a relationship:
- Start a conversation
- Engage in other people's conversations
- People appreciated their content and the events they were planning to organize
Once the group members recognize you, you can use the platform to generate interest in your products.
5. Use SEO to increase website traffic
High ranking your website in search results will increase your website traffic. To get a better rank, you must do search engine optimization on your website. Some of the basics of SEO include:
- Keyword optimization on both landing pages and blog content
- Constantly great content post
- Link building
Again, it is important to point out that SEO and content creation can be technical and time-consuming.
6. Create a sales funnel
Once you know who you are targeting and decide how to reach them, you need to have a plan to collect contact information. The first part of the process involves funneling all prospects into a standard form or landing page that encourages them to share their contact information, usually in exchange for a free gift, coupon, sample, or any other value-added incentive.
7. Use an email newsletter to build relationships
Now that you’re in touch with prospects, it’s time to cultivate those relationships so you can take them from the lead stage through sales (and ultimately repeat sales). One of the best ways to keep in touch with your prospects is through an email newsletter.
How to do payments with stripe checkoutLaravel

How to do payments with stripe checkoutLaravel
Payments gateways are very useful components of any e-commerce store. One of the popular payment gateways is Stripe. it's becoming more popular nowadays.
Stripe's simple definition is :
We bring together everything that’s required to build websites and apps that accept payments and send payouts globally. Stripe’s products power payments for online and in-person retailers, subscription businesses, software platforms and marketplaces, and everything in between. ~ Stripe
To begin this laravel tutorial, I hope you already have fresh laravel repo.
Stripe Configuration with Laravel
Run the following command to install stripe :
composer require stripe/stripe-php
if you don't have a Stripe account, you'll want to set that up and add your API keys. Add the following to your .env file.
STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret
Publish Migrations Files From Stripe
php artisan vendor:publish --tag="cashier-migrations"
And Run migrations by hitting the following command
php artisan migrate
Setup Stripe Controller
Now create a stripe controller by hitting the following command:
php artisan make:controller StripeController
namespace App\Http\Controllers;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Stripe\Checkout\Session;
use Stripe\Exception\ApiErrorException;
/**
* Class FeaturedCompanySubscriptionController
*/
class StripeControlle extends AppBaseController
{
public function createSession(Request $request)
{
setStripeApiKey();
$session = Session::create([
'payment_method_types' => ['card'],
'customer_email' => $userEmail,
'line_items' => [
[
'price_data' => [
'product_data' => [
'name' => 'Make '.$company->user->first_name.' as featured Company',
],
'unit_amount' => 100 * 100,
'currency' => 'USD',
],
'quantity' => 1,
'description' => '',
],
],
'client_reference_id' => '1234',
'mode' => 'payment',
'success_url' => url('payment-success').'?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => url('failed-payment?error=payment_cancelled'),
]);
$result = [
'sessionId' => $session['id'],
];
return $this->sendResponse($result, 'Session created successfully.');
}
public function paymentSuccess(Request $request)
{
$sessionId = $request->get('session_id');
//
}
public function handleFailedPayment()
{
//
}
}
Define Routes
Route::post('stripe-charge', 'StripeController@createSession');
Route::get('payment-success', 'StripeController@paymentSuccess');
Route::get('failed-payment', 'StripeController@handleFailedPayment');
Setup From View file
Here we are going to create stripe session from the backend and redirect to the stripe checkout page once we will receive the sessionId from the backend.
Assume that makePaymentURL is something like "APP_URL/stripe-charge".
Now let's say when you hit the submit form of stripe it will call MakePaymentURL and that URL returns your session ID which we will use to redirect to the stripe checkout page.
$(document).on('click', '#makePayment', function () {
$(this).addClass('disabled');
$.post(makePaymentURL, payloadData).done((result) => {
let sessionId = result.data.sessionId;
stripe.redirectToCheckout({
sessionId: sessionId,
}).then(function (result) {
$(this).html('Make Featured').removeClass('disabled');
manageAjaxErrors(result);
});
}).catch(error => {
$(this).html('Make Featured').removeClass('disabled');
manageAjaxErrors(error);
});
});
That's it, after entering proper details into stripe you will get a success callback to a related route, where you can perform related actions.
How to add Shadow and Text on ImageView in AndroidAndroid Development

How to add Shadow and Text on ImageView in AndroidAndroid Development
Basically, it works like a stack where each view is stacked on top of the other.
Create a drawable file for shadow view and assign the name image_shadow and add the below code in this file.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<gradient
android:angle="270"
android:centerX="300%"
android:endColor="#99000000"
android:startColor="#00000000"
android:type="linear" />
<size
android:width="270dp"
android:height="60dp" />
<stroke
android:width="1dp"
android:color="#878787" />
</shape>
Now, open the XML file and add the below code into it, and set this drawable file as view background.
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="250dp"
android:scaleType="centerCrop"
android:src="@drawable/shopping_image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<View android:id="@+id/view"
android:layout_width="250dp"
android:layout_height="250dp"
android:background="@drawable/image_shadow"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textColor="@android:color/white"
android:text="Write your text here"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/view"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
That's it. You should be ready to go.
Show saved annotations from database in document using PDFTronJavascript

Show saved annotations from database in document using PDFTronJavascript
Here we will learn how to import annotations saved in the database using PDFTron.
In my last blog, we have learned how to save annotations in the database.
Events for import annotation
At the time of document load, we will get all annotations saved in the database using AJAX call and then we'll import that annotation. Now the question is if we import annotation then that will be drawn and again annotation changed event will fire and again annotation will be saved (as I say in my last blog), so this will become an infinite flow, but we can overcome this problem by checking if an annotation is imported or not. If an annotation is not imported then only we'll save annotation in the database process otherwise we'll ignore it.
When we draw any annotation, the "annotationChanged" event will be fired, and check if it is an imported annotation, then we can ignore it(eg, save annotation process).
Here is an example of how to import annotations from the database.
Example
WebViewer({
path: 'path_to_the_PDFTron_'lib'_folder_on_your_server',
css: 'webviewer_css',
licenseKey: 'YOUR_PDF_TRON_LICENSE_KEY',
initialDoc: 'YOUR_FILE URL' //url of a file to load
}, document.getElementById('viewer'))
.then(function (instance) {
let docViewer = instance.docViewer;
let annotManager = instance.annotManager;
annotManager.on('annotationChanged', (annots, action, e) => {
//if annotation is imported we'll return
if (e.imported) return;
//when document will loaded we'll get annotations fro db
docViewer.on('documentLoaded', function () {
$.ajax({
url: `URL_TO_SAVE_ANNOTATION`,
type: 'GET',
success: function (result) {
if (result.success) {
result.data.forEach(annotationObj => {
annotManager.importAnnotations(annotationObj.annotation);
});
}
},
error: function (result) {
console.log(result);
}
});
});
});
});