const token = await Notifications.getExpoPushTokenAsync()
await axiosConfig.post("pushToken", { token });
this code works perfectly on (Production mode and Expo Client app)
When i use expo build:android for APK. app crash when I call this function
try out:
For a ./google-services.json:
{
"project_info": {
"project_number": "…",
"firebase_url": "…",
"project_id": "…",
"storage_bucket": "…"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "…",
"android_client_info": {
"package_name": "…"
}
},
"api_key": [
{
"current_key": "KEY_KEY_KEY_KEY_KEY"
}
]
},
please make app.json:
{
"expo": {
"…": "…",
"android": {
"package": "…",
"googleServicesFile": "./google-services.json",
"config": {
"googleSignIn": {
"apiKey": "KEY_KEY_KEY_KEY_KEY"
}
}
https://github.com/expo/expo/issues/7727#issuecomment-611544439
I had similar problem and I solved it by enabling my notification for Expo client on my device.
Related
I previously made an extension with a language support for g-code. Now I'm converting it into a language server. The problem is that my extension had some commands which I registered on the client side. When using the exact same code on the language client (the client of the language server) it does not work. Does someone have an idea why that could be?
I tried copy pasting all the dependencies etc. but with no success.
Here is the source code of the package.json of the language client:
{
"name": "lsp-sample-client",
"description": "VSCode part of a language server",
"author": "Microsoft Corporation",
"license": "MIT",
"version": "0.0.1",
"publisher": "vscode",
"engines": {
"vscode": "^1.63.0"
},
"main": "./out/extension.js",
"activationEvents": [
"onLanguage:gcode",
"onLanguage:cpl"
],
"contributes": {
"commands": [
{
"command": "lineNumberer.Renumber1",
"title": "Renumber Step 1"
},
{
"command": "lineNumberer.Renumber10",
"title": "Renumber Step 10"
},
{
"command": "lineNumberer.Renumber100",
"title": "Renumber Step 100"
},
{
"command": "lineNumberer.Renumber1000",
"title": "Renumber Step 1000"
}
],
"menus": {
"editor/context": [
{
"command": "lineNumberer.Renumber1",
"title": "Renumber Step 1"
},
{
"when": "editorLangId == gcode || editorLangId == cpl",
"command": "lineNumberer.Renumber10",
"title": "Renumber Step 10"
},
{
"when": "editorLangId == gcode || editorLangId == cpl",
"command": "lineNumberer.Renumber100",
"title": "Renumber Step 100"
},
{
"when": "editorLangId == gcode || editorLangId == cpl",
"command": "lineNumberer.Renumber1000",
"title": "Renumber Step 1000"
}
]
}
},
"dependencies": {
"vscode-languageclient": "^7.0.0"
},
"devDependencies": {
"#types/vscode": "^1.63.0",
"#vscode/test-electron": "^2.1.2"
}
}
Here is the content of the client extension.ts:
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as path from 'path';
import { workspace, ExtensionContext, commands } from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
} from 'vscode-languageclient/node';
import { incrementLineNumbersBy } from './lineNumberer/lineNumberer';
let client: LanguageClient;
export function activate(context: ExtensionContext) {
const renumber1 = commands.registerCommand('lineNumberer.Renumber1', () => {
const step = 1;
incrementLineNumbersBy(step);
});
const renumber10 = commands.registerCommand('lineNumberer.Renumber10', () => {
const step = 10;
incrementLineNumbersBy(step);
});
const renumber100 = commands.registerCommand('lineNumberer.Renumber100', () => {
const step = 100;
incrementLineNumbersBy(step);
});
const renumber1000 = commands.registerCommand('lineNumberer.Renumber1000', () => {
const step = 1000;
incrementLineNumbersBy(step);
});
context.subscriptions.push(renumber1);
context.subscriptions.push(renumber10);
context.subscriptions.push(renumber100);
context.subscriptions.push(renumber1000);
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join('server', 'out', 'server.js')
);
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
}
};
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for gcode and cpl documents
documentSelector: [
{ scheme: 'file', language: 'gcode' },
{ scheme: 'file', language: 'cpl' }
],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
};
// Create the language client and start the client.
client = new LanguageClient(
'languageServerExample',
'Language Server Example',
serverOptions,
clientOptions
);
// Start the client. This will also launch the server
client.start();
}
export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
}
return client.stop();
}
I managed to solve the problem myself. The problem was that you have to add the contributes commands part in the ./package.json (the outer most package.json) and not the one from the language client.
I am using apollo-server-express to build graphql server
My resolvers in server.js is as simple as that
const express = require('express');
const { ApolloServer } = require('apollo-server-express');
const { importSchema } = require('graphql-import');
const typeDefs = importSchema('./src/schema.graphql');
const prisma = require('./src/prisma');
const server = new ApolloServer({
typeDefs,
resolvers: {
Query: {
users(parent, args, { prisma }, info) {
return prisma.query.users(args, info);
}
}
},
context: ({ req }) => ({ ...req, prisma })
});
const app = express();
server.applyMiddleware({ app });
app.listen({ port: 4000 }, () =>
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
);
and i am getting this error when i run users query
{
"errors": [
{
"message": "Cannot use GraphQLObjectType \"Query\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"users"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot use GraphQLObjectType \"Query\" from another module or realm.",
"",
"Ensure that there is only one instance of \"graphql\" in the node_modules",
"directory. If different versions of \"graphql\" are the dependencies of other",
"relied on modules, use \"resolutions\" to ensure only one version is installed.",
"",
"https://yarnpkg.com/en/docs/selective-version-resolutions",
"",
"Duplicate \"graphql\" modules cannot be used at the same time since different",
"versions may have different capabilities and behavior. The data from one",
"version used in the function from another could produce confusing and",
"spurious results.",
" at instanceOf (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql\\jsutils\\instanceOf.js:28:13)",
" at isObjectType (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql\\type\\definition.js:116:34)",
" at TypeInfo.enter (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql\\utilities\\TypeInfo.js:163:61)",
" at Object.enter (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql\\language\\visitor.js:369:16)",
" at Object.visit (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql\\language\\visitor.js:242:26)",
" at replaceFieldsWithFragments (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql-tools\\src\\transforms\\ReplaceFieldWithFragment.ts:67:10)",
" at ReplaceFieldWithFragment.transformRequest (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql-tools\\src\\transforms\\ReplaceFieldWithFragment.ts:45:22)",
" at D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql-tools\\src\\transforms\\transforms.ts:24:21",
" at Array.reduce (<anonymous>)",
" at Object.applyRequestTransforms (D:\\00. DEVELOPMENT\\FULL PROJECTS\\social-template-2\\node_modules\\graphql-binding\\node_modules\\graphql-tools\\src\\transforms\\transforms.ts:21:21)"
]
}
}
}
],
"data": null
}
and here is my package.json
{
"name": "social-template-2",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"server": "nodemon --ext js,graphql --exec babel-node server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server-express": "^2.17.0",
"babel-cli": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"bcryptjs": "^2.4.3",
"express": "^4.17.1",
"graphql": "^15.3.0",
"graphql-import": "^1.0.2",
"jsonwebtoken": "^8.5.1",
"prisma-binding": "^2.3.16"
},
"devDependencies": {
"#prisma/cli": "^2.7.1",
"concurrently": "^5.3.0",
"nodemon": "^2.0.4"
}
}
Do you have any idea what could be wrong here ?
There is probably another graphql in your node_modules.
try to check it with:
find node_modules -name graphql
then look in package.json of each graphql modules and check what version is there.
Finally, what helped in my case is just uninstalling all packages that contain graphql and install them again together:
npm uninstall apollo-server apollo-server-express graphql neo4j-driver neo4j-graphql-js
npm install apollo-server apollo-server-express graphql neo4j-driver neo4j-graphql-js --force
When i try to download a file from API Graph accesing to Drive or Sites with javascript on SPFx this return undefined.
my webpart code:
import { Version } from '#microsoft/sp-core-library';
import {
BaseClientSideWebPart,
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '#microsoft/sp-webpart-base';
import * as strings from 'Docx2PdfWebPartStrings';
import { MSGraphClient } from '#microsoft/sp-http';
export interface IDocx2PdfWebPartProps {
description: string;
}
export default class Docx2PdfWebPart extends BaseClientSideWebPart<IDocx2PdfWebPartProps> {
public async render(): Promise<void> {
const client: MSGraphClient = await this.context.msGraphClientFactory.getClient();
var tenant = 'test';
var siteID = `${tenant}.sharepoint.com,12adb250-26f4-4dbb-9545-71d029bad763,8fdc3f56-2d6d-42d9-9a4d-d684e73c341e`;
var fileID = '01MBNFB7EIQLARTATNE5G3XDJNYBD2A3IL';
var fileName = 'Test.docx';
//This work
var site = await client.api(`/sites/${tenant}.sharepoint.com:/sites/dev:/drive?$select=id,weburl`).get();
console.log(site);
try {
//This not work
var fileFromDrive = await client.api(`/drive/root:/${fileName}:/content?format=pdf`).get();
console.log(fileFromDrive);
var fileFromSite = await client.api(`/sites/${siteID}/drive/items/${fileID}/content?format=pdf`).get();
console.log(fileFromSite);
} catch (error) {
console.log(error);
}
this.domElement.innerHTML = `<h1>Hola Mundo</h1>`;
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}
The chrome console log
But when i use Graph Explorer it works correctly
This is my package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "docx-2-pdf-client-side-solution",
"id": "f4b5db4f-d9ff-463e-b62e-0cc9c9e94089",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Sites.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "Files.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "Files.ReadWrite.All"
},
{
"resource": "Microsoft Graph",
"scope": "Sites.ReadWrite.All"
}
]
},
"paths": {
"zippedPackage": "solution/docx-2-pdf.sppkg"
}
}
I use the following articles
https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=javascript
https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=javascript#code-try-1
Try using the callback property instead of await:
client.api(`/drive/root:/${fileName}:/content?format=pdf`).get((err, response) => console.log("your response:", err, response));
Problem
I want to capture the audio output of a tab automatically. I'm currently thinking of doing this using Puppeteer (headful), by loading an extension that uses chrome.tabCapture.capture. From my Puppeteer script, I evaluate code within the extensions background.js to get the tab capture started. However, chrome.runtime.lastError.message is set to Requested device not found.
The extension works as expected outside of Puppeteer and in a Chrome browser.
Any idea why I'm getting Requested device not found?
What does the extension's background.js look like?
function startRecording() {
chrome.tabCapture.capture(options, stream => {
if (stream === null) {
console.log(`Last Error: ${chrome.runtime.lastError.message}`);
return;
}
try {
const recorder = new MediaRecorder(stream);
} catch (err) {
console.log(err.message);
}
recorder.addEventListener('dataavailable', event => {
const { data: blob, timecode } = event;
console.log(`${timecode}: ${blob}`);
});
const timeslice = 60 * 1000;
recorder.start(timeslice);
});
}
What does the relevant part of your Puppeteer script look like?
...
const targets = await browser.targets();
const backgroundPageTarget = targets.find(target => target.type() === 'background_page' && target.url().startsWith('chrome-extension://abcde/'));
const backgroundPage = await backgroundPageTarget.page();
const test = await backgroundPage.evaluate(() => {
startRecording();
return Promise.resolve(42);
});
...
Extension Manifest:
{
"name": "Test",
"description": "",
"version": "1.0",
"icons": {
"128": "icon.png"
},
"manifest_version": 2,
"browser_action": {
"default_popup": "test.html"
},
"background": {
"scripts": [
"background.js"
],
"persistent": true
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"all_frames": false,
"js": [
"contentScript.js"
]
}
],
"permissions": [
"activeTab",
"tabs",
"tabCapture",
"storage"
]
}
ODL version: Carbon
I'm having a problem with getting BGP-LS into the Network Topology. As you can see from below REST output, I set up "bgp-example" and homed to an external eBGP linkstate peer. "effective-rib-in", "adj-rib-in", and "adj-rib-out" all populate - but "loc-rib" does not. For some reason, it is not inheriting the linkstate afi/safi.
I tried debugs for bgp & karaf but saw nothing out of the ordinary (that I could see) - any help would be much appreciated.
thanks
Erik
*bgp configuration
http://192.168.3.42:8181/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/protocols/protocol/openconfig-policy-types:BGP/bgp-example
{
"protocol": [
{
"name": "bgp-example",
"identifier": "openconfig-policy-types:BGP",
"bgp-openconfig-extensions:bgp": {
"global": {
"config": {
"router-id": "192.168.3.42",
"as": 65000
}
},
"neighbors": {
"neighbor": [
{
"neighbor-address": "192.168.3.41",
"config": {
"peer-type": "EXTERNAL",
"peer-as": 65111
},
"afi-safis": {
"afi-safi": [
{
"afi-safi-name": "bgp-openconfig-extensions:LINKSTATE"
}
]
}
}
]
}
}
}
]
}
*loc-rib empty
http://192.168.3.42:8181/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example/loc-rib
{
"loc-rib": {
"tables": [
{
"afi": "bgp-types:ipv4-address-family",
"safi": "bgp-types:unicast-subsequent-address-family",
"bgp-inet:ipv4-routes": {}
}
]
}
}
as you can see, linkstate is making it into every rib, except loc-rib
http://192.168.3.42:8181/restconf/operational/bgp-rib:bgp-rib/rib/bgp-example
{
"rib": [
{
"id": "bgp-example",
"peer": [
{
"peer-id": "bgp://x.x.x.x",
"supported-tables": [
{
"afi": "bgp-types:ipv4-address-family",
"safi": "bgp-types:unicast-subsequent-address-family"
},
{
"afi": "bgp-linkstate:linkstate-address-family",
"safi": "bgp-linkstate:linkstate-subsequent-address-family"
}
],
"effective-rib-in": {
"tables": [
{
"afi": "bgp-linkstate:linkstate-address-family",
"safi": "bgp-linkstate:linkstate-subsequent-address-family",
"bgp-linkstate:linkstate-routes": {
"linkstate-route": [
{
"route-key": "AAMAMAIAAAAAAAAFMgEAABoCAAAEAAD+VwIBAAQAAAAAAgMABgEAFQmQAAEJAAUgCv0YAQ==",
"identifier": 1330,
"advertising-node-descriptors": {
"as-number": 65111,
"domain-id": 0,
"isis-node": {
"iso-system-id": "AQAVCZAA"
}
},
"prefix-descriptors": {
"ip-reachability-information": "x.x.x.x/32"
},
"attributes": {
"origin": {
"value": "igp"
},
"ipv4-next-hop": {
"global": "x.x.x.x"
},
"as-path": {
"segments": [
{
"as-sequence": [
65111
]
}
]
}
},
"protocol-id": "isis-level2"
}
}
rest of output truncated for brevity/readability
OK, figured this out.... turns out I had not enabled LINKSTATE afi/safi in the global config for ODL BGP. I had to DELETE my existing global config, then POST, add neighbors, peers, etc. Now I have the linkstate DB in the loc-rib, AND it's made it to the network topology - BUT - no idea how to view this topology via DLUX....