ToddFrankson
Members-
Content Count
40 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ToddFrankson
-
I have Push Notifications working just fine....... What I want to do now is the following: When the user taps the notification and the App is closed, I want the App to open and display the Notification within the app(in a TText for example). My problem seems to be that when the notification is tapped, and the app launches, the notification is cleared before the app can open. Is there a way to do what I want?
-
I'm confused now....The Docs say there's no title and body, but you are saying there is, or did you just type the JSON up? Or was this sent thru FCMRebooted?
-
So what does PushService.StartupNotifications contain when the App cold starts?
-
@Dave Nottage I noticed this in the documentation: Note: The push notification title and body are not available in DataObject when the application is launched (coldstart) by tapping the notification in the Notification Center. So there is no way to display the notification, on a cold start, within the App??
-
I was looking to keep track of notifications for the user to be able to look back at them.
-
If the App isn't running, and receives the notification, can I, for example, add it to a text file at that point?
-
I expect you don't have an SSLHandler, which is required if you are using SSL by setting TLS to Explicit.
-
Meta-Delphi question about web hosting..
ToddFrankson replied to jglosz's topic in Network, Cloud and Web
Not true. most Windows servers run Plesk, which is far better than cpanel. -
How to solve System Out of Resources in TScrollBox
ToddFrankson replied to araujoarthur's topic in VCL
I use an In memory table (TFDMemtable) for somethings I am working on, assigning only the records that will be visible on the screen at any given time. So if I will see 20 -30 items, I reuse the controls, just change the data in them as someone "scrolls" . It's an illusion, but visually it seems extremely fast, and low memory overhead due to only a set number of visual components -
So I have the ability to set the MACOS wallpaper on the current screen using this code (I believe Dave Nottage posted it). procedure SetDesktopBackground(const ImagePath: string; const FillColor: TAlphaColor); var NSFileURL: NSURL; NSWorkspace1: NSWorkspace; MainScreen: NSScreen; Error: NSError; begin try // Convert Delphi file path to NSURL NSFileURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(StrToNSStr(ImagePath))); NSWorkspace1 := TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace); MainScreen := TNSScreen.Wrap(TNSScreen.OCClass.mainScreen); // Set the desktop image for the main screen if not NSWorkspace1.setDesktopImageURL(NSFileURL, MainScreen, nil, @Error) then begin ShowMessage('Failed to set desktop image: ' + NSStrToStr(Error.localizedDescription)); end; except on E: Exception do begin ShowMessage('Error setting desktop image: ' + E.Message); end; end; end; My problem has been the 3rd parameter in SetDesktopImageURL..... Evidently it takes an NSDictionary. I have spent 3 days attempting to get this part to work with various attempts at translating ObjectiveC and swift code, using my brain and even several AI coding websites. Nothing I seem to do actually builds the dictionary. Can anyone lend me a hand? I have managed to find the following constants (Not defined in Delphi BTW): const NSImageScaleNone = 0; NSImageScaleAxesIndependently = 1; NSImageScaleProportionallyUpOrDown = 2; NSImageScaleProportionallyDown = 3; Here's the Dictionary documentation : https://developer.apple.com/documentation/foundation/nsdictionary?language=objc And the Documentation on the keys in the dictionary(Defined in the constants above): https://developer.apple.com/documentation/appkit/nsworkspace/desktopimageoptionkey?language=objc Thanks If someone could help me understand this, so I can get past it, I'd appreciate it.
-
I think you posted it....I may be mistaken. Here is 1 variation: procedure SetDesktopBackground(const ImagePath: string; const FillColor: TAlphaColor); var Err: NSError; Options: NSMutableDictionary; ImageURL: NSURL; FillColorObj: NSColor; begin // Convert the image file path to NSURL ImageURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(NSStr(ImagePath))); if ImageURL = nil then begin Showmessage('Failed to create NSURL for the image file.'); Exit; end; // Create a dictionary for desktop image options Options := TNSMutableDictionary.Wrap(TNSMutableDictionary.OCClass.dictionary); // Set the desktop image fill color FillColorObj := TNSColor.Wrap(TNSColor.OCClass.colorWithCalibratedRed( TAlphaColorRec(FillColor).R / 255, TAlphaColorRec(FillColor).G / 255, TAlphaColorRec(FillColor).B / 255, TAlphaColorRec(FillColor).A / 255)); Options.setObject(FillColorObj, NSWorkspaceDesktopImageFillColorKey); // Set the desktop image scaling to none Options.setObject(TNSNumber.Wrap(TNSNumber.OCClass.numberWithInt(NSImageScaleProportionallyUpOrDown)), NSWorkspaceDesktopImageScalingKey); // Set the desktop image for the main screen if not TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace).setDesktopImageURL(ImageURL, TNSScreen.Wrap(TNSScreen.OCClass.mainScreen), Options, @Err) then begin if Err <> nil then Writeln(Format('Error setting desktop background: %s', [NSStrToStr(Err.localizedDescription)])); end; end; It hangs here: Options.setObject(FillColorObj, NSWorkspaceDesktopImageFillColorKey); Here is another: procedure SetDesktopColor(const Color: TAlphaColor); var Err: NSError; Options: NSMutableDictionary; URL: NSURL; TempFile: string; begin // Create a temporary file path for the color image TempFile := TPath.Combine(TPath.GetTempPath, 'SolidColorDesktop.png'); // Create a solid color image CreateSolidColorImage(Color, TempFile); // Load the image as an NSURL URL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(NSStr(TempFile))); if URL = nil then begin Showmessage('Failed to create NSURL for the temporary file.'); Exit; end; // Create a mutable dictionary for desktop image options Options := TNSMutableDictionary.Wrap(TNSMutableDictionary.OCClass.dictionary); // Set the desktop image fill color (not used in this case) Options.setObject(TNSColor.Wrap(TNSColor.OCClass.whiteColor), NSWorkspaceDesktopImageFillColorKey); // Set the desktop image scaling Options.setObject(TNSNumber.Wrap(TNSNumber.OCClass.numberWithInt(NSImageScaleNone)), NSWorkspaceDesktopImageScalingKey); // Set the desktop image for the main screen if not TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace).setDesktopImageURL(URL, TNSScreen.Wrap(TNSScreen.OCClass.mainScreen), Options, @Err) then begin if Err <> nil then Showmessage(Format('Error setting desktop color: %s', [NSStrToStr(Err.localizedDescription)])); end; end; I have tried using NSDictionary in place of NSMutableDictionary, and used the SetValue method. That gives me an Exception in the onButtonUp event deep in FMX code. I tried this to get the current settings: function GetCurrentDesktopImageOptions: TDictionary<string, string>; var Options: NSDictionary; KeyEnumerator: NSEnumerator; Key: Pointer; OptionKey: string; OptionValue: string; ResultDict: TDictionary<string, string>; begin ResultDict := TDictionary<string, string>.Create; try Options := TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace) .desktopImageOptionsForScreen(TNSScreen.Wrap(TNSScreen.OCClass.mainScreen)); if Options <> nil then begin KeyEnumerator := Options.keyEnumerator; while True do begin Key := KeyEnumerator.nextObject; if Key = nil then Break; OptionKey := NSStrToStr(TNSString.Wrap(Key)); OptionValue := NSStrToStr(TNSString.Wrap(Options.objectForKey(Key))); ResultDict.Add(OptionKey, OptionValue); end; end; Result := ResultDict; except ResultDict.Free; raise; end; end; This returns absolutely nothing. What am I doing wrong? I'd love to pass the dictionary with the Scaled image, and background color in the dictionary. Apple documentation gives me a headache. I'm surprised I got this far.....
-
Explain how else you display a sum to the user, without displaying the data in a control This will be good to learn.
-
Are there any Issues with TRestRequest and IOS? The following Code runs on Android, Windows 32bit & 64bit, and MacOS fine, but on IOS I get nothing in the TRestResponse contents: procedure TForm1.Button1Click(Sender: TObject); begin Memo1.lines.clear; TTask.run(Procedure Begin RestRequest1.execute; End).Start; end; And the RestRequest Handler- procedure TForm1.RESTRequest1AfterExecute(Sender: TCustomRESTRequest); begin Try Begin Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Memo1.lines.add(Accesstoken); TDialogservice.showmessage('Access Token: ' + AccessToken); End; Except on E:Exception do TDialogservice.showmessage(E.message); End; end; Everytime I hit Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); the restresponse content is ''. But only on IOS. Anyone have ideas where to look? Maybe a property I need to set? I can post the form code if needed.
-
And just like that, Response code of 0 with ZERO code changes. Even the Postman App on IOS fails following the instructions from the website. There's something fishy with REST and IOS
-
Got it. It seems IOS had to have a slightly different URL............ The API provider needs better documentation. All is good in the universe again. Thanks for helping me brainstorm
-
1-It should be, bu tit is not. Content=''.- Works on all platforms but IOS-I used the REST Debugger to generate the objects. 2-On all other platforms it is, but not on IOS 3- the response code is 0- i have been digging into the HTTPClient in the rest Request. It seems on IOS it's doing a handoff to the OS with a callback. Line 517-522 of System.Net.HTTPClient.mac is where it fails on IOS Emulator (So I can step through the code) LResponse.FDone := False; FDataTasks.AddTask(LRequest.FDataTask, LResponse); try LRequest.FDataTask.resume; while not LResponse.FDone do InternalWaitMessage(0.01); --> This procedure Located at 330-338: procedure InternalWaitMessage(AInterval: Single); var TimeoutDate: NSDate; begin TimeoutDate := TNSDate.Wrap(TNSDate.OCClass.dateWithTimeIntervalSinceNow(AInterval)); TNSRunLoop.Wrap(TNSRunLoop.OCClass.currentRunLoop).runMode(NSDefaultRunLoopMode, TimeoutDate); if TThread.CurrentThread.ThreadID <> MainThreadID then Sleep(Trunc(AInterval * 1000)); end; Lines 1309-on in System.Net.HTTPCLient is where the LResponse.Cancelled is set to true: if LRequest.FCancelled then----->Cancelled is false; Exit; LExecResult := DoExecuteRequest(LRequest, LResponse, AContentStream); if LRequest.FCancelled then--------------Cancelled is true Exit; case LExecResult of TExecutionResult.Success: ------>Status is success, but the exit above spits us out begin if not SameText(LRequest.FMethodString, sHTTPMethodHead) and (LResponse.FStream <> nil) then LResponse.DoReadData(LResponse.FStream); if LRequest.FCancelled then Exit; Status := LResponse.GetStatusCode;------------Status code is 200 but Cancelled set to true means we've exited case Status of 200: begin Break; end; 401: ...... And today I get an SSL error at line 529 of System.Net.HTTPClient.mac: else if LResponse.FError <> nil then-------------------------> raise ENetHTTPClientException.CreateResFmt(@SNetHttpClientErrorAccessing, [LResponse.FError.code, LRequest.FURL.ToString, NSStrToStr(LResponse.FError.localizedDescription)]) End;
-
https://docwiki.embarcadero.com/RADStudio/Athens/en/Submitting_Your_Android_App_to_Google_Play#Android_App_Bundle_Support
-
Same issue. That was where this started. procedure TForm1.Button1Click(Sender: TObject); begin RESTRequest1.AcceptEncoding := 'gzip, deflate, br'; Memo1.lines.clear; RestRequest1.ExecuteAsync(MyHandler,true,true,nil); end; procedure TForm1.myHandler; begin Try Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Memo1.lines.add(Accesstoken); showmessage('Access Token: ' + AccessToken); Except on E:Exception do showmessage(E.message); End; When I tap button1 to fire RestRequest1.ExecuteAsync(MyHandler,true,true,nil); almost immediately I go right to Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Then it hits the Exception, where Accesstoken is '', and never shows the error message.
-
I tried that too, It works on all platforms except IOS. Thats what lead me to try this. It's like the RESTRequest1AfterExecute comes back before the request is completed
-
I need some help in figuring out services.... I will be writing an app that needs to stay running, and every certain interval of time (at least 15 minutes or more-user configurable), open a file(in the apps folder) read it and then close the file(there's more to it but that is basics). I believe a foreground service is best, with it sticky, and start on boot.... I have those pieces. So the questions I have are the following: Like a weather app, I'd like it to stay in the Notification Panel at the top. How does that work? anyone have sample code? See the image.....How do I make my App stay like that in the notification panel, and then when the panel is "closed" it displays the current temperature. Has anyone done that in Delphi? I also will have the interface allowing to see the contents of the file the service opens, I believe I have some samples for that, but if it helps it will be a few configuration text items, and the UI will also open the same file, blocking the Service from doing so when the UI is launched. I believe I have that covered as well....
-
Not necessarily solved. Just trying to understand the process.......... I've read that foreground services have some specific permissions that need to be requested, along with specific reasons why. I think I have a grasp on that now... As for the notifications, I can get that working by modifying your Kastri Demo Actually.....I used the JNotification_Builder and JNotificationManager to create the first Notification. For updates, I used the JNotificationCompat_Builder Still having issues getting the App Icon Using the following: var MainAppContext: JContext; AppIcon: Integer; Begin // Get the main application context by package name MainAppContext := TAndroidHelper.Context.getApplicationContext; // Fetch the application icon from the main application context AppIcon := MainAppContext.getPackageManager.getApplicationInfo( MainAppContext.getPackageName, 0).icon; ...... //other code related to building either the Notification_Builder or JNotificationCompat_Builder. .... End; The Icon is always a white box.
-
Embarcadero\Studio\22.0\Samples\Object Pascal\Multi-Device Samples\Device Sensors and Services\DownloadServiceDemo
ToddFrankson posted a topic in FMX
So out of the box, the demo doesn't work for me. The first problem was the Read and Write External Storage permissions are deprecated. So, I changed the permissions to use the media files..... changed the line in the service from : LFileName := TPath.Combine(TPath.GetSharedDownloadsPath, LFileName); to LFileName := TPath.Combine(TPath.GetDocumentsPath, LFileName); in hopes it would work. Still nothing. This is my first pass at services, so I don't know diddly...... 1-Can I debug a service? I have tried but can't seem to make it happen. 2- Does the service and the App reside in the same "directory" on android, and have access to the same folders? I'm at a point where the app runs fine, but no notification comes from the server indicating the file downloaded, and the app never loads it....... Any one have 2 cents?? -
Embarcadero\Studio\22.0\Samples\Object Pascal\Multi-Device Samples\Device Sensors and Services\DownloadServiceDemo
ToddFrankson replied to ToddFrankson's topic in FMX
Disregard.....Needed the Post notification permission -
What new features would you like to see in Delphi 13?
ToddFrankson replied to PeterPanettone's topic in Delphi IDE and APIs
Dave, it would be best to have a private conversation regarding why. I actually have been thinking of reaching out to you.... I'll PM you. -
What new features would you like to see in Delphi 13?
ToddFrankson replied to PeterPanettone's topic in Delphi IDE and APIs
While that is awesome, it should have been provided, and in the future, should be provided by the producer of the software. No one there ever thought, "I bet people will love installing 200+ addons one at a time, instead of a select a group and install...."