You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to work my way through building a perfect 'franz' style app in macpin.
So far, I've got Gmail, Gcal and Slack setup, and the app reliably loads all three sites and they function 99% perfectly fine.
That last 1% though, is driving me nuts. Whenever the app starts, all 3 tabs show their respective webapp's request to display desktop notifications.
However, no notifications are ever displayed, and the app doesn't 'remember' the notification settings after a restart.
Below is what I've hacked together.
/* * eslint-env applescript * eslint-env builtins * eslint-env es6 * eslint eqeqeq:0, quotes:0, space-infix-ops:0, curly:0*/"use strict";const{app, BrowserWindow, WebView}=require('@MacPin');letinjectTab=require('app_injectTab.js');letenDarken=require('enDarken.js');letslackTab={url: 'https://app.slack.com/client/T0FSN3Z16/D19MH3CQ2/thread/C2K8LNETG-1574707732.133300',authorizedOriginsForNotifications: ['https://app.slack.com','https://app.slack.com:443'],style: ['autodark']}letsfCalendarTab={url: 'https://calendar.google.com/calendar/r/customday?pli=1',authorizedOriginsForNotifications: ['https://notifications.google.com','https://notifications.google.com:443'],}letsfMailTab={url: 'https://mail.google.com/mail/u/0/#inbox',authorizedOriginsForNotifications: ['https://notifications.google.com','https://notifications.google.com:443']}varSFCalendar=newWebView(sfCalendarTab);varSFMail=newWebView(sfMailTab);varSFSlack=newWebView(slackTab);letbrowser=newBrowserWindow();app.on("postedDesktopNotification",(note,tab)=>{console.log(Date()+`[${tab.url}] posted HTML5 desktop notification: ${note.id}`);console.log(JSON.stringify(note));returnfalse});app.on('handleClickedNotification',(note)=>{console.log("App signals a clicked notification: "+JSON.stringify(note));returnfalse;});app.on('didWindowOpenForURL',function(url,newTab,tab){if(url.length>0&&newTab)console.log(`window.open(${url})`);returnfalse;// macpin will popup(newTab, url) and return newTab to tab's JS});letopenInChrome=function(tab){console.log(`app.js: opening (${tab.url}) in chrome`);switch(app.platform){case"OSX":
app.openURL(tab.url,"com.google.Chrome");break;case"iOS":
app.openURL(tab.url,tab.url.startsWith("https://") ? "googlechromes" : "googlechrome");break;}};// handles cmd-line and LaunchServices openURL()sapp.on('launchURL',(url)=>{console.log("app.js: launching "+url);varcomps=url.split(':'),scheme=comps.shift(),addr=comps.shift();switch(scheme+':'){default:
browser.tabSelected=newWebView({url: url});//FIXME: retains???!}});// app.on('launchURL', (url) => new $.WebView({url: url}));app.on('networkIsOffline',(url,tab)=>{console.log(`Could not navigate to ${url} - network is offline!`);});letsetAgent=function(agent,tab){tab.userAgent=agent;};letgetAgent=function(tab){tab.evalJS(`window.alert(navigator.userAgent);`);};app.on('AppWillFinishLaunching',(AppUI)=>{//browser.unhideApp();browser.addShortcut('DarkMode',[],enDarken);// http://user-agents.mebrowser.addShortcut('Show current User-Agent',[],getAgent);if(app.doesAppExist("com.google.Chrome"))browser.addShortcut('Open in Chrome',[],openInChrome);//browser.addShortcut('HTML5 editor -> preview', editorPreview);//editorPreview should find editor tab (passed by ref?) and render its source// WebView.init ends up with WebViewInitProps.handlers: <__NSFrozenDictionaryM>if(app.platform==="OSX")app.changeAppIcon('icon.png');//browser.tabSelected = new $.WebView({url: 'http://github.com/kfix/MacPin'});AppUI.browserController=browser;// make sure main app menu can get at our shortcutsconsole.log(app.browserController);// shuffle the _tabs using the tabs Proxybrowser.tabs.push(SFMail);browser.tabs.push(SFCalendar);browser.tabs.push(SFSlack);});app.on('AppFinishedLaunching',(launchURLs)=>{console.log(launchURLs);});app.on('AppShouldTerminate',(app)=>{console.log("main.js shutting down!");docTab=null;gitTab=null;});// https://www.lucidchart.com/techblog/2018/02/14/javascriptcore-the-holy-grail-of-cross-platform///app.loadAppScript('fetchDeps.js`);//let fetchURL = require('fetchURL');
The text was updated successfully, but these errors were encountered:
I'm trying to work my way through building a perfect 'franz' style app in macpin.
So far, I've got Gmail, Gcal and Slack setup, and the app reliably loads all three sites and they function 99% perfectly fine.
That last 1% though, is driving me nuts. Whenever the app starts, all 3 tabs show their respective webapp's request to display desktop notifications.
However, no notifications are ever displayed, and the app doesn't 'remember' the notification settings after a restart.
Below is what I've hacked together.
The text was updated successfully, but these errors were encountered: