Notifications not sending in Tauri - notifications

I'm building a simple desktop app using Tauri and Svelte but I'm having trouble with the notification module. I have allowlisted all APIs in tauri.conf.json.
The code below runs and prints permissionGranted as true (line 10) but the sendNotifications seem to have no effect.
const notify = async () => {
let permissionGranted = await isPermissionGranted();
if (!permissionGranted) {
const permission = await requestPermission();
permissionGranted = permission === "granted";
}
if (permissionGranted) {
sendNotification("Tauri is awesome!");
sendNotification({ title: "TAURI", body: "Tauri is awesome!" });
console.log(permissionGranted);
}
}
notify();
I also tried using the Notifications API in the console itself but nothing happens and the created Notification object has no properties.
Notification.permission; // "granted"
const n = new Notification("New Message", { body: "hello" }); // {} empty object
Platform and Versions
Environment
› OS: Mac OS 12.4.0 X64
› Node.js: 17.2.0
› npm: 8.13.2
› pnpm: 6.11.0
› yarn: 1.22.15
› rustup: 1.25.1
› rustc: 1.62.0
› cargo: 1.62.0
› Rust toolchain: stable-x86_64-apple-darwin
Packages
› #tauri-apps/cli [NPM]: 1.0.5
› #tauri-apps/api [NPM]: 1.0.2
› tauri [RUST]: 1.0.5,
› tauri-build [RUST]: 1.0.4,
› tao [RUST]: 0.12.2,
› wry [RUST]: 0.19.0,
App
› build-type: bundle
› CSP: unset
› distDir: ../public
› devPath: http://localhost:8080/
› framework: Svelte
› bundler: Rollup
› wry [RUST]: 0.19.0,
tauri.conf.json
{
"$schema": "../node_modules/#tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm run dev",
"devPath": "http://localhost:8080",
"distDir": "../public"
},
"package": {
"productName": "d",
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"all": true
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128#2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.tauri.dev",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "d",
"width": 800
}
]
}
}

It seems there's an issue with the Tauri notifications API on MacOS in development mode.
#4965

Related

expo ios build failing on fastlane

I am trying to build my expo app for ios (eas build --platform ios) but it keeps failing at fastlane. My previous build (2 months ago) was successful so I don't know what the problem is now.
Here is the error -
Here is how my eas.json looks like:
{
"cli": {
"version": ">= 0.53.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": {"image": "latest"}
},
"preview": {
"distribution": "internal"
},
"production": {
}
},
"submit": {
"production": {
"ios": {
"appleId": "raxxxxxx",
"ascAppId": "xxxxxx",
"appleTeamId": "xxxxxx"
}
}
}
}
How can I resolve this?
My app is just a simple one, here is how it is structured:

Apk file which made using eas build of react native expo cli is not works on real device

I've made an app using React Native Expo Cli. It works fine on Expo Go App and I've generated apk file using eas build --profile development --platform android and eas build --platform android. But these does not work on real device.
I've used eas build for making apk because earlier I was using expo build:android but now If I write this command on cmd and hit enter then after some seconds it is showing "Unsupported SDK version: our app builders do not support SDK version 45, yet. The latest SDK version is 45.0.0. Unsupported SDK version". You can check my app.json and eas.json file.
app.json
{
"expo": {
"name": "RoyalVivahVendor",
"slug": "RoyalVivahVendor",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.royalvivah.royalvivahvendor",
"versionCode": 1
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
eas.json
{
"cli": {
"version": ">= 0.52.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"android": {
"buildType": "apk"
}
}
},
"submit": {
"production": {}
}
}

configure google admob for expo

I am trying to integrate googles Admob service into my expo initialized react native app via the expo-ads-admob package. the package works successfully in the expo-go development environment, however when I build the app and via eas build --profile development --platform ios and install it onto my phone, it immediately closes as soon as I open it. I have already removed all imports of the Admob components within the app so it seems like just installing the package itself causes the app to crash at runtime. Since the app builds successfully, there are no error messages I can use to start debugging, any help would be greatly appreciated. This is the configuration in my app.json if that's relevant
{
"expo": {
"name": "MyApp",
"slug": "MyApp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#FFF"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"config": {
"googleMobileAdsAppId": "ca-app-pub-TESTID"
},
"bundleIdentifier": "com.package.identifier"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFF"
},
"config": {
"googleMobileAdsAppId": "ca-app-pub-TESTID"
},
"package": "com.package.identifier"
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
expo-ads-admob is deprecated, so when using EAS Build the app breaks.
Expo itself recommends using react-native-google-mobile-ads, or try uninstalling EAS with npm uninstall -g eas-cli and using expo build.

NPM CLI returns command not found

I have created a simple CLI to bootstrap projects with inquirer and have successfully published it to NPM. However, when installing it with
npm i -g noobject
it's successfully loading and installing.
When running
noobject
in the cmd line, it does return "command not found" and when running
npx noobject its returning the following.
npm ERR! could not determine executable to run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Me\AppData\Local\npm-cache\_logs\2022-02-13T17_28_00_374Z-debug-0.log
I have tried it both on windows 10 and linux ubuntu 20.4.
Here is my index.js: https://sourceb.in/ZGZMWKU8tb
#! /usr/bin/env node
const inquirer = require("inquirer");
const fs = require("fs");
// FULL SOURCE TREE: https://github.com/vKxni/noobject
const CURR_DIR = process.cwd();
const CHOICES = fs.readdirSync(`${__dirname}/templates`);
// Questions asked to the User
const QUESTIONS = [
{
name: "project-choice",
type: "list",
message: "What project would you like to generate?",
choices: CHOICES,
},
{
name: "project-name",
type: "input",
message: "Project name:",
validate: (input) => {
if (/^([A-Za-z\-\_\d])+$/.test(input)) return true;
else
return "Project name may only include letters, numbers, underscores and hashes.";
},
},
];
// Send a prompt to choose a template
inquirer.prompt(QUESTIONS).then((answers) => {
const projectChoice = answers["project-choice"];
const projectName = answers["project-name"];
const templatePath = `${__dirname}/templates/${projectChoice}`;
// Create the folder with the project name choosed by the user
fs.mkdirSync(`${CURR_DIR}/${projectName}`);
createDirectoryContents(templatePath, projectName);
console.log(`✅ Successfully created ${projectName}`);
});
const createDirectoryContents = (templatePath, newProjectPath) => {
const filesToCreate = fs.readdirSync(templatePath);
filesToCreate.forEach((file) => {
const origFilePath = `${templatePath}/${file}`;
const stats = fs.statSync(origFilePath);
if (stats.isFile()) {
const contents = fs.readFileSync(origFilePath, "utf8");
if (file === ".npmignore") file = ".gitignore";
const writePath = `${CURR_DIR}/${newProjectPath}/${file}`;
fs.writeFileSync(writePath, contents, "utf8");
console.log(`⚠️ Created ${writePath}`);
} else if (stats.isDirectory()) {
fs.mkdirSync(`${CURR_DIR}/${newProjectPath}/${file}`);
createDirectoryContents(
`${templatePath}/${file}`,
`${newProjectPath}/${file}`
);
}
});
};
Here is my package.json:
{
"name": "noobject",
"version": "1.2.8",
"description": "Project generator written in NodeJS",
"main": "index.js",
"scripts": {
"noobject": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vKxni/noobject.git",
"keywords": [
"node",
"generator",
"project",
"noobject"
],
"author": "vKxni",
"license": "ISC",
"dependencies": {
"inquirer": "^8.2.0"
},
"bin": {
"noobject": "index.js"
}
}
}
(As a pastebin: https://sourceb.in/CF4ydtNccG).
I hope anyone can help me so I can bootstrap projects and config files easier and faster.
Your problem is that you're missing a } for repository, so bin is actually inside repository. You can see there's a doubled } in the second to last line.
{
"name": "noobject",
"version": "1.2.8",
"description": "Project generator written in NodeJS",
"main": "index.js",
"scripts": {
"noobject": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vKxni/noobject.git",
/* <----- should be here */
"keywords": [
"node",
"generator",
"project",
"noobject"
],
"author": "vKxni",
"license": "ISC",
"dependencies": {
"inquirer": "^8.2.0"
},
"bin": {
"noobject": "index.js"
}
} /* <----- wrong place! */
}
If you fix that, it works:
{
"name": "noobject",
"version": "1.2.8",
"description": "Project generator written in NodeJS",
"main": "index.js",
"scripts": {
"noobject": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vKxni/noobject.git",
},
"keywords": [
"node",
"generator",
"project",
"noobject"
],
"author": "vKxni",
"license": "ISC",
"dependencies": {
"inquirer": "^8.2.0"
},
"bin": {
"noobject": "index.js"
}
}

Detox react-native build success, "Detox can't seem to connect to the test app(s)!" (iOS)

Managed to build successfully, but I suspect I have something wrong with my binaryPath in .detoxrc?
react-native: 0.64.1
detox: 18.22.1
.detoxrc.json
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"skipLegacyWorkersInjection": true,
"apps": {
"ios": {
"type": "ios.app",
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/myappname.app",
"build": "xcodebuild -workspace ios/myappname.xcworkspace -configuration Release -scheme myappname id=ED0F3373-A57D-481B-86DA-D87007C00F85 -sdk iphonesimulator"
}
},
"devices": {
"simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 12"
}
}
},
"configurations": {
"ios": {
"device": "simulator",
"app": "ios"
}
}
}
config.json
{
"maxWorkers": 1,
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 5000,
"testNamePattern": "**.spec.js",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
react-native app running in iOS Simulator. detox test -c ios leads to:
detox[72935] ERROR: [APP_UNREACHABLE] Detox can't seem to connect to the test app(s)!
HINT:
The test app might have crashed prematurely, or has had trouble setting up the connection.
Refer to our troubleshooting guide, for full details: > https://github.com/wix/Detox/blob/master/docs/Troubleshooting.RunningTests.md#tests-execution-hangs
The same thing happened to me running on M1 Apple Silicon—fixed it by downgrading to 17.14.9