Post

Replies

Boosts

Views

Activity

UIScrollView stretches it's subview when it scrolls under safe area
I have a UIImageView and a bottom container view inside a UIScrollView. I set the scrollView's contentInsetAdjustmentBehavior to .never because I want the scrollView's content to anchor to top of the view, such that the content of the scroll view, in this case the imageView, shows inside the top safe area. The ImageView currently shows all the way to the top. However, the problem is that when the user scrolls down, and the bottomContainer view meets the top Safe Area, the top of the bottomContainer view stretches. The bottom container has all its constraint set for its subviews, from top to bottom. I don't understand why the bottomContainer view would stretch vertically. The constraint for these views are as follows: // adds view as subview with `translatesAutoResizingMasksIntoConstraints = false self.view.add(subviews: mainScrollView) NSLayoutConstraint.activate([ self.mainScrollView.topAnchor.constraint(equalTo: self.view.topAnchor), self.mainScrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor), self.mainScrollView.leftAnchor.constraint(equalTo: self.view.leftAnchor), self.mainScrollView.rightAnchor.constraint(equalTo: self.view.rightAnchor), self.mainScrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: self.view.widthAnchor) ]) // adds views as subviews with `translatesAutoResizingMasksIntoConstraints = false self.mainScrollView.add(subviews: [self.profileImageView, self.bottomContainer]) // adds constraints to caller view's edges on axis self.mainScrollView.make(views: [self.profileImageView, self.bottomContainer], flushAlongAxes: [.horizontal]) // Adds VLF constraints to views on the callers edges self.mainScrollView.addConstraints( withVisualFormat: "V:|[profileView(\(self.profileViewHeight))]-(-10)-[bottomContainer]-15-|", views: ["profileView": self.profileImageView, "bottomContainer": self.bottomContainer]) I will attach a some screenshots to clarify what is happening: Here is how it is supposed to look: Here is how it stretches as the bottomContainer scrolls under the SafeArea: How do I prevent the bottomContainer from stretching when it scrolls under the top safe area?
0
0
298
Aug ’24
APNs key revoked causes “BadDeviceToken” in APN send() result
I am trying to send push notifications with an image inside a Firebase Cloud Function using node.js (v10) and a module called 'node-apn'. When I realized I need the APNs key, I reached out to a former dev for it's location. Apparently, it was not to be found so the original APN key was revoked and a new one was generated in Apple Dev console. This APN key was then added to the Firebase Cloud Messaging Settings in the Console. The iOS app is setup to register device tokens and accept notifications via APNs. My problem is when I send the APN in the javascript cloud function, it results in an error "BadDeviceToken" (400). This happens to all the device tokens stored under my own user doc in Firestore. I realize this is because those tokens are made with the original APNs key, but now that I've added the new one, how do the device tokens get reset? Here is the node.JS code I am using: 					var key = Buffer.from("-----BEGIN PRIVATE KEY-----\nMI9T3g.....jGGUkioo\n-----END PRIVATE KEY-----"); 								let options = { 										token: { 												key: key, 												keyId: "66X*****", 												teamId: "*******" 										}, 										production: true 								}; 								var apnProvider = new apn.Provider(options); 								var note2 = new apn.Notification(); 								note2.title = publisher.Username + " posted a new Mag!" 								note2.mutableContent = true 								note2.pushType = "alert" 								note2.payload = { 										"fcm_options": { 												"image": publisher.magImage 										} 								} 								return apnProvider.send(note2, deviceTokens).then((response) => { 										response.sent.forEach(token => { 												console.log("Notification sent to " + token) 										}) 										response.failed.forEach(failure => { 												if (failure.error) { 														console.log("Error : " + failure.error.message) 												} else { 														console.log("Failure Status : " + failure.status) 														console.log("Failure response : " + failure.response.reason) 														console.log("Failure device : " + failure.device) 												} 										}) 										return response 								}) 						}); We have a Firestore backend and have the newly created APNs Key properly added to the Firebase Cloud Messaging settings.
1
0
2.8k
Jun ’20