Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added disconnect method, fixed TS #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions docs/components/LoginComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ import { ref } from 'vue'
import { useVsipInject } from '@/index'
import { VcForm, VcFormItem, VcButton, VcInput } from '@voicenter-team/voicenter-ui-plus'

import { initializeApp } from 'firebase/app';
import { getMessaging, getToken } from "firebase/messaging";

const { actions } = useVsipInject()

const loginFormRef = ref<typeof VcForm>()
Expand Down Expand Up @@ -114,6 +117,48 @@ const rules = {
]
}

const firebaseConfig = window.firebaseConfig

//const parsed = window.firebaseConfig

const VAPID_KEY = window.VAPID_KEY

const app = initializeApp(firebaseConfig);

//const messaging = getMessaging();

let token: string

async function requestNotificationPermission() {
const messaging = getMessaging(app);

window.messaging = messaging

try {
// Request notification permission
const permission = await Notification.requestPermission();

if (permission === 'granted') {
console.log('Notification permission granted.');

// Get the FCM token
token = await getToken(messaging, { vapidKey: VAPID_KEY });

if (token) {
console.log('FCM Token:', token);
// Use the token for sending notifications from your server
} else {
console.log('No registration token available. Request permission to generate one.');
}
} else {
console.log('Notification permission denied.');
}
} catch (error) {
console.error('An error occurred while requesting permission:', error);
}
}

requestNotificationPermission()


// eslint-disable-next-line
Expand All @@ -125,7 +170,7 @@ const login = async (event: any) => {
return
}

const pnParams = loginData.value.extraHeaders.split(';').reduce(
/*const pnParams = loginData.value.extraHeaders.split(';').reduce(
(acc, item) => {
if (typeof item !== 'string') {
return acc
Expand All @@ -142,13 +187,20 @@ const login = async (event: any) => {
return acc
},
{}
)
)*/

const pnExtraHeaderes = {
'pn-provider': 'fcm',
'pn-param': 'voicenter-mobile',
'pn-prid': token || '',
'pn-strategy': 'all'
}

actions.init(
loginData.value.domain,
loginData.value.extension,
loginData.value.password,
pnParams
pnExtraHeaderes
)
}

Expand Down
63 changes: 62 additions & 1 deletion docs/components/VSipPhone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
>
{{ muteButtonText }}
</VcButton>

<!-- <VcButton
color="primary"
@click="register"
>
REGISTER
</VcButton>-->
</section>

<section class="w-full pb-4">
Expand Down Expand Up @@ -218,6 +225,59 @@ import { useVsipInject } from '@/index'
import { computed, ref } from 'vue'
import { CONSTRAINTS } from '~/enum'

import { getMessaging, onMessage } from "firebase/messaging";

//const messaging = getMessaging();
/*onMessage(window.messaging, (payload) => {
console.log('Message received. ', payload);

register()
});*/

/*import { initializeApp } from 'firebase/app';
import { getMessaging, getToken } from "firebase/messaging";

const firebaseConfig = window.firebaseConfig

//const parsed = window.firebaseConfig

const VAPID_KEY = window.VAPID_KEY

const app = initializeApp(firebaseConfig);

//const messaging = getMessaging();

let token: string

async function requestNotificationPermission() {
const messaging = getMessaging();

try {
// Request notification permission
const permission = await Notification.requestPermission();

if (permission === 'granted') {
console.log('Notification permission granted.');

// Get the FCM token
token = await getToken(messaging, { vapidKey: VAPID_KEY });

if (token) {
console.log('FCM Token:', token);
// Use the token for sending notifications from your server
} else {
console.log('No registration token available. Request permission to generate one.');
}
} else {
console.log('Notification permission denied.');
}
} catch (error) {
console.error('An error occurred while requesting permission:', error);
}
}

requestNotificationPermission()*/

const { state, actions } = useVsipInject()
const {
selectedInputDevice,
Expand Down Expand Up @@ -249,7 +309,8 @@ const {
answerCall,
moveCall,
mute,
unmute
unmute,
register
} = actions

/* Data */
Expand Down
3 changes: 3 additions & 0 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { resolve } from 'path'

export default defineNuxtConfig({
devtools: { enabled: true },
devServer: {
https: true
},
app: {
head: {
meta: [
Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@nuxt/content": "^2.13.2",
"@voicenter-team/opensips-js": "^1.0.95",
"@voicenter-team/voicenter-ui-plus": "^0.5.20",
"firebase": "^10.13.1",
"voicenter-team-documentation-template": "https://github.com/VoicenterTeam/documentation-template.git"
},
"devDependencies": {
Expand Down
Empty file.
Loading