notification

This commit is contained in:
venbatechnologies@gmail.com 2019-06-26 19:12:20 +05:30
parent b933f58ba1
commit e8de2e46fb
14 changed files with 1021 additions and 23 deletions

View File

@ -18,7 +18,9 @@
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
"src/favicon.ico",
"src/firebase-messaging-sw.js",
"src/manifest.json"
],
"styles": [
"node_modules/quill/dist/quill.snow.css",

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@
"@angular/common": "^6.0.0-rc.5",
"@angular/compiler": "^6.0.0-rc.5",
"@angular/core": "^6.0.0-rc.5",
"@angular/fire": "^5.2.1",
"@angular/flex-layout": "^6.0.0-beta.18",
"@angular/forms": "^6.0.0-rc.5",
"@angular/http": "^6.0.0-rc.5",
@ -42,6 +43,7 @@
"d3": "^4.9.1",
"dragula": "3.7.2",
"file-saver": "^2.0.0",
"firebase": "^6.2.3",
"font-awesome": "4.7.0",
"hammerjs": "2.0.8",
"intl": "^1.2.4",

View File

@ -1,16 +1,31 @@
import { Component } from '@angular/core';
import { MessagingService } from "./shared/messaging.service";
import { TranslateService} from '@ngx-translate/core';
import { AwsService } from './AwsService/aws.service';
@Component({
selector: 'app-root',
template: '<router-outlet></router-outlet>'
})
export class AppComponent {
constructor(translate: TranslateService) {
message;
constructor(translate: TranslateService,
private messagingService: MessagingService,
public aws: AwsService) {
translate.addLangs(['en', 'fr']);
translate.setDefaultLang('en');
const browserLang: string = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
}
ngOnInit() {
const userId = this.aws.getlocale();
this.messagingService.requestPermission(userId)
this.messagingService.receiveMessage()
this.message = this.messagingService.currentMessage
}
}

View File

@ -47,6 +47,14 @@ import { AuthGuard } from './_guard/auth.guard';
import { RoleMenuItemsPipe } from './layouts/role-menu-items.pipe';
import { ResizableModule } from 'angular-resizable-element';
import { AngularFireMessagingModule } from '@angular/fire/messaging';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFireModule } from '@angular/fire';
import { MessagingService } from './shared/messaging.service';
import { environment } from '../environments/environment';
import { AsyncPipe } from '../../node_modules/@angular/common';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@ -97,6 +105,10 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
}
}),
FlexLayoutModule,
AngularFireDatabaseModule,
AngularFireAuthModule,
AngularFireMessagingModule,
AngularFireModule.initializeApp(environment.firebase),
],
providers: [
{
@ -113,7 +125,8 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
provide:HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
multi: true
}
},
MessagingService, AsyncPipe
],
entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog],
bootstrap: [AppComponent]

View File

@ -108,8 +108,8 @@
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-raised-button mat-icon-button class="mr-1 mb-1" matTooltip="Add More Co-Applicant" matTooltipPosition="above" color="primary" type="button" (click)="addCoApplicant(emptyData)"><mat-icon>add</mat-icon></button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="updatePdApplicant(_EditApplicantForm.value)"><mat-icon>save</mat-icon></button>
<!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="updatePdApplicant(_EditApplicantForm.value)"><mat-icon>save</mat-icon></button> -->
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="updatePdApplicant(_EditApplicantForm.value)" [disabled]="disableAfterSubmit===true"><mat-icon>save</mat-icon></button>
</mat-dialog-actions>
</form>

View File

@ -113,7 +113,7 @@
<mat-form-field style="width: 96%">
<input matInput
placeholder="Address at which PD Visit actually done"
placeholder="Enter actual PD address"
formControlName="alternative_address"
[value]="alter_addr.get('alternative_address').value | titlecase"
required autocomplete="off">

View File

@ -59,11 +59,11 @@
</mat-form-field>
<mat-form-field style="width: 28%" *ngIf="lenderShortName == 'CLIX'">
<mat-select placeholder="Is there a Total Fund is Disclose ? "
<mat-select placeholder="Total fund requirement"
formControlName="is_there_total_fund">
<mat-option>Select</mat-option>
<mat-option value="yes disclose">Yes, Disclosed</mat-option>
<mat-option value="no not disclosed">No, Not Disclosed</mat-option>
<mat-option value="yes disclose">Disclosed</mat-option>
<mat-option value="no not disclosed">Not Disclosed</mat-option>
</mat-select>
</mat-form-field>
<span *ngIf="loanDetailsForm.controls['is_there_total_fund'].value == 'yes disclose'">

View File

@ -0,0 +1,69 @@
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/database';
import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { mergeMapTo } from 'rxjs/operators';
import { take } from 'rxjs/operators';
import { BehaviorSubject } from 'rxjs'
@Injectable()
export class MessagingService {
currentMessage = new BehaviorSubject(null);
constructor(
private angularFireDB: AngularFireDatabase,
private angularFireAuth: AngularFireAuth,
private angularFireMessaging: AngularFireMessaging) {
this.angularFireMessaging.messaging.subscribe(
(_messaging) => {
_messaging.onMessage = _messaging.onMessage.bind(_messaging);
_messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);
}
)
}
/**
* update token in firebase database
*
* @param userId userId as a key
* @param token token as a value
*/
updateToken(userId, token) {
// we can change this function to request our backend service
this.angularFireAuth.authState.pipe(take(1)).subscribe(
() => {
const data = {};
data[userId] = token
this.angularFireDB.object('fcmTokens/').update(data)
})
}
/**
* request permission for notification from firebase cloud messaging
*
* @param userId userId
*/
requestPermission(userId) {
this.angularFireMessaging.requestToken.subscribe(
(token) => {
// console.log(token);
this.updateToken(userId, token);
},
(err) => {
console.error('Unable to get permission to notify.', err);
}
);
}
/**
* hook method when new notification received in foreground
*/
receiveMessage() {
this.angularFireMessaging.messages.subscribe(
(payload) => {
// console.log("new message received. ", payload);
this.currentMessage.next(payload);
})
}
}

View File

@ -1,4 +1,13 @@
export const environment = {
production: true,
apiEndpoint: 'https://ssa.sineedge.com/sparqtest/api/'
apiEndpoint: 'https://ssa.sineedge.com/sparqtest/api/',
firebase: {
apiKey: "AIzaSyCzmyM0WJ0wdLf8UsYoZ4GreICimyt7SEk",
authDomain: "ssa-push.firebaseapp.com",
databaseURL: "https://ssa-push.firebaseio.com",
projectId: "ssa-push",
storageBucket: "ssa-push.appspot.com",
messagingSenderId: "627754063571",
appId: "1:627754063571:web:8cfa56d80607267b"
}
};

View File

@ -5,6 +5,16 @@
export const environment = {
production: false,
apiEndpoint: 'https://ssa.sineedge.com/sparqapi/api/',
firebase: {
apiKey: "AIzaSyCzmyM0WJ0wdLf8UsYoZ4GreICimyt7SEk",
authDomain: "ssa-push.firebaseapp.com",
databaseURL: "https://ssa-push.firebaseio.com",
projectId: "ssa-push",
storageBucket: "ssa-push.appspot.com",
messagingSenderId: "627754063571",
appId: "1:627754063571:web:8cfa56d80607267b"
},
region: 'ap-south-1',
@ -25,5 +35,5 @@ export const environment = {
s3_endpoint: '',
accessToken:'',
//apiUrl:'http://localhost/sparqapi/api/'
apiEndpoint: 'https://ssa.sineedge.com/sparqapi/api/'
};

View File

@ -0,0 +1,15 @@
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/5.5.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/5.5.0/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
'messagingSenderId': '627754063571'
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();

View File

@ -8,6 +8,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
<!-- <title>Optima - Angular 6 Material Admin Template</title> -->
<title> PD Genie </title>

View File

@ -0,0 +1,3 @@
{
"gcm_sender_id": "103953800507"
}